Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to contribute to terraform-provider-aws

How to contribute to terraform-provider-aws

Terraform meetup tokyo #1 Lightningh Talk
https://terraform-jp.connpass.com/event/137865/

Takeshi Kondo

August 01, 2019
Tweet

More Decks by Takeshi Kondo

Other Decks in Technology

Transcript

  1. How to contribute to
    terraform-provider-aws
    Takeshi Kondo
    SRE at Quipper
    2019/08/01
    Terraform Meetup Tokyo#1

    View full-size slide

  2. • Run test
    • Set debug
    • Read code
    • Read Issue
    • Read Pull Request

    View full-size slide

  3. Merged 3 Pull Requests

    View full-size slide

  4. Merged 3 Pull Requests
    See my blog for details: Google “πφϫλϦϚΠϥΠϑ”

    - Terraform importͷ࣮૷

    - Terraform aws provider PR / lambdaͷnode engine
    v6.10ͷEOLରԠ

    View full-size slide

  5. • Join Terraform Source Code
    Reading
    • Join #codereading at
    Terraform-jp slack

    View full-size slide

  6. Agenda
    • Basic source code structure

    • 4 Steps of preparing

    • 6 Steps of contributing

    View full-size slide

  7. Agenda
    • Basic source code structure

    • 4 Steps of preparing

    • 6 Steps of contributing

    View full-size slide

  8. Basic source code structure
    • terraform-provider-aws

    • aws/

    • data_source_aws_iam_policy.go

    • data_source_aws_iam_policy_test.go

    • resource_aws_iam_policy.go

    • resource_aws_iam_policy_test.go

    • website/
    %FpOFE
    w $SFBUF
    w 3FBE
    w 6QEBUF
    w %FMFUF
    w *NQPSUFS

    View full-size slide

  9. Agenda
    • Basic source code structure

    • 4 Steps of preparing

    • 6 Steps of contributing

    View full-size slide

  10. 4 Steps of preparing
    • Clone and build

    • Set debug

    • Run test

    • Push to fork

    View full-size slide

  11. 4 Steps of preparing
    • Clone and build

    • Set debug

    • Run test

    • Push to fork

    View full-size slide

  12. Clone and build (Thanks @minamijoyo)
    • git clone [email protected]:hashicorp/terraform.git

    • cd terraform

    • git checkout v0.12.3

    • export GO111MODULE=on

    • make dev -> $GOPATH/bin/terraform

    • git clone [email protected]:terraform-providers/
    terraform-provider-aws.git

    • cd terraform-provider-aws

    • git checkout v2.21.1

    • export GO111MODULE=off

    • make

    • See Hackmd for details

    • https://hackmd.io/HeEmX_dPQAaEANhiH1lKQQ?view

    View full-size slide

  13. 4 Steps of preparing
    • Clone and build

    • Set debug

    • Run test

    • Push to fork

    View full-size slide

  14. Set debug (Thanks @minamijoyo)
    • Terraform/main.go

    • terraform-provider-aws/main.go
    func main() {
    + log.SetFlags(log.Llongfile)
    // Override global prefix set by go-dynect during init()
    log.SetPrefix("")
    os.Exit(realMain())
    import (
    "github.com/hashicorp/terraform/plugin"
    "github.com/terraform-providers/terraform-provider-aws/aws"
    + "log"
    )
    func main() {
    + log.SetFlags(log.Llongfile)
    plugin.Serve(&plugin.ServeOpts{
    ProviderFunc: aws.Provider})
    }

    View full-size slide

  15. Set debug (Thanks @minamijoyo)
    • Terraform/main.go

    • terraform-provider-aws/main.go
    func main() {
    + log.SetFlags(log.Llongfile)
    // Override global prefix set by go-dynect during init()
    log.SetPrefix("")
    os.Exit(realMain())
    import (
    "github.com/hashicorp/terraform/plugin"
    "github.com/terraform-providers/terraform-provider-aws/aws"
    + "log"
    )
    func main() {
    + log.SetFlags(log.Llongfile)
    plugin.Serve(&plugin.ServeOpts{
    ProviderFunc: aws.Provider})
    }
    • See Hackmd for details

    • https://hackmd.io/HeEmX_dPQAaEANhiH1lKQQ?view

    • Terraform৬ਓೖ໳: ೔ʑͷӡ༻ͰֶΜͩ஌ݟΛ
    ୶ʑͱ·ͱΊΔ / @minamijoyo

    • TerraformΛσόοά͢Δٕज़

    • https://qiita.com/minamijoyo/items/1f57c62bed781ab8f4d7

    View full-size slide

  16. 4 Steps of preparing
    • Clone and build

    • Set debug

    • Run test

    • Push to fork

    View full-size slide

  17. Run test
    cat .envrc \

    export AWS_PROFILE=“chaspy”

    make testacc \

    TESTARGS=‘-run=TestAccAWSEcsCluster_basic’

    Note that resources are actually created
    and charged for your account

    View full-size slide

  18. 4 Steps of preparing
    • Clone and build

    • Set debug

    • Run test

    • Push to fork

    View full-size slide

  19. Push to fork
    • # fork the repository

    • # terraform-providers/terraform-provider-aws

    • # -> chaspy/terraform-provider-aws

    • git remote add fork https://github.com/chaspy/
    terraform-provider-aws.git

    • git push fork

    View full-size slide

  20. Agenda
    • Basic source code structure

    • 4 Steps of preparing

    • 6 Steps of contributing

    View full-size slide

  21. 6 Steps of contributing
    • Determine the issue you solve

    • Make a sandbox

    • Apply the sample code

    • Reproduce the issue with debug log

    • Read the reference PR

    • Read a code and commit and push

    View full-size slide

  22. 6 Steps of contributing
    • Determine the issue you solve

    • Make a sandbox

    • Apply the sample code

    • Reproduce the issue with debug log

    • Read the reference PR

    • Read a code and commit and push
    • Ask contributor (Thanks @kterada0509)

    • See “good first issue” label

    • Recommend: Support import issue

    View full-size slide

  23. 6 Steps of contributing
    • Determine the issue you solve

    • Make a sandbox

    • Apply the sample code

    • Reproduce the issue with debug log

    • Read the reference PR

    • Read a code and commit and push

    View full-size slide

  24. 6 Steps of contributing
    • Determine the issue you solve

    • Make a sandbox

    • Apply the sample code

    • Reproduce the issue with debug log

    • Read the reference PR

    • Read a code and commit and push

    View full-size slide

  25. 6 Steps of contributing
    • Determine the issue you solve

    • Make a sandbox

    • Apply the sample code

    • Reproduce the issue with debug log

    • Read the reference PR

    • Read a code and commit and push

    View full-size slide

  26. 6 Steps of contributing
    • Determine the issue you solve

    • Make a sandbox

    • Apply the sample code

    • Reproduce the issue with debug log

    • Read the reference PR

    • Read a code and commit and push

    View full-size slide

  27. 6 Steps of contributing
    • Determine the issue you solve

    • Make a sandbox

    • Apply the sample code

    • Reproduce the issue with debug log

    • Read the reference PR

    • Read a code and commit and push

    • Reviewed in a few days

    • They review kindly

    View full-size slide

  28. Conclusion
    • Anyone can send a pull request

    • Not afraid of Terraform by contributing

    • Motivated to use the latest version

    View full-size slide

  29. • Join Terraform Source Code
    Reading
    • Next: #2 2nd Sep. (Mon)
    • Join #codereading at
    Terraform-jp slack

    View full-size slide

  30. • @officel / @raki

    • Organizer of Terraform-jp
    Special Thanks
    • @morihaya

    • Co-organizer meetup
    • @minamijoyo

    • Lead code-reading
    • @kterada0509 / teraken0509

    • Lead code-reading

    View full-size slide

  31. Thank You!
    chaspy
    chaspy_ / chaspy_en
    Site Reliability Engineer

    at Quipper
    Takeshi Kondo
    SRE Lounge Terraform-jp

    View full-size slide