Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Terraform example #1478

Merged
merged 27 commits into from
Oct 23, 2023
Merged

feat: Terraform example #1478

merged 27 commits into from
Oct 23, 2023

Conversation

skal111
Copy link
Contributor

@skal111 skal111 commented Oct 13, 2023

Issue #, if available:
#1445

Description of changes:

Terraform example
TFLint and validate in the pr-build.yml
Included remarks from previous PR

Checklist

Breaking change checklist

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

terraform -version
cd examples/powertools-examples-core/terraform
terraform init
terraform validate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we do a plan too ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your call, if you think it adds value to the build.

Copy link
Contributor Author

@skal111 skal111 Oct 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

terraform plan was added but terraform validate fails because there are no AWS credentials available in the CI environment. They are required by terraform AWS provider.
I tried, but was unsuccesful at adding

I can't reproduce this error in my environment so I'm struggling to fix it.

I suggest we simply configure the provider with region = "us-east-1" (or any other region) as it seems to pass

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe because you don't have permission to do that as it's from a fork

Copy link
Contributor

@jeromevdl jeromevdl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still a few comments

@scottgerring
Copy link
Contributor

Related to #1458

@scottgerring scottgerring changed the title #1458 including remarks from previous PR feat: Terraform example Oct 13, 2023
@scottgerring
Copy link
Contributor

My previous comments were addressed! @skal111 do you mind updating the same PR next time, it makes it easier to see what's happened 💪

@skal111
Copy link
Contributor Author

skal111 commented Oct 13, 2023

My previous comments were addressed! @skal111 do you mind updating the same PR next time, it makes it easier to see what's happened 💪

Yeah ok apologies, just found out you can update a PR :)
There you go.
Latest commit includes fixes relevant to this PR conversation

@jeromevdl
Copy link
Contributor

@skal111, there is a problem in the latest build, with the plan (here). Don't know if we can leverage the same technic as the E2E tests (see here) to assume a role and have terraform plan working.

@codecov-commenter
Copy link

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (533ac9a) 78.58% compared to head (9019e73) 78.58%.
Report is 1 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1478   +/-   ##
=========================================
  Coverage     78.58%   78.58%           
  Complexity      650      650           
=========================================
  Files            74       74           
  Lines          2508     2508           
  Branches        259      259           
=========================================
  Hits           1971     1971           
  Misses          455      455           
  Partials         82       82           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@jeromevdl jeromevdl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job thank you!

@@ -68,6 +68,27 @@ jobs:
run: |
cd examples/powertools-examples-core/gradle
./gradlew build
- name: Setup Terraform
Copy link
Contributor

@jeromevdl jeromevdl Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- name: Setup Terraform
- name: Setup AWS credentials
uses: aws-actions/configure-aws-credentials@5fd3084fc36e372ff1fff382a39b10d03659f355 # v2.2.0
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }}
aws-region: ${{ env.AWS_REGION }}
- name: Setup Terraform

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you also need to add this after the env (line 56)

    permissions:
      id-token: write # needed to interact with GitHub's OIDC Token endpoint.
      contents: read

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, let me try again

Copy link
Contributor

@jeromevdl jeromevdl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I saw the build failing

@sonarcloud
Copy link

sonarcloud bot commented Oct 19, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@jeromevdl jeromevdl merged commit 34fc20e into aws-powertools:main Oct 23, 2023
7 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants