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: Infrastructure Manager workspace blueprint #271

Merged

Conversation

josephdt12
Copy link
Collaborator

This blueprint creates an opinionated workflow for actuating Terraform resources using Infrastructure Manager using GitHub/GitLab and Cloud Build.

This blueprint creates an opinionated workflow for actuating Terraform resources using Infrastructure Manager using GitHub/GitLab and Cloud Build.
@bharathkkb bharathkkb self-assigned this Mar 11, 2024
@josephdt12 josephdt12 closed this Mar 11, 2024
@josephdt12 josephdt12 reopened this Mar 11, 2024
Copy link
Member

@bharathkkb bharathkkb left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @josephdt12

examples/im_cloudbuild_workspace_github/main.tf Outdated Show resolved Hide resolved
modules/im_cloudbuild_workspace/github.tf Outdated Show resolved Hide resolved
modules/im_cloudbuild_workspace/outputs.tf Outdated Show resolved Hide resolved
modules/im_cloudbuild_workspace/repo.tf Outdated Show resolved Hide resolved
modules/im_cloudbuild_workspace/sa.tf Show resolved Hide resolved
modules/im_cloudbuild_workspace/versions.tf Outdated Show resolved Hide resolved
}

provider_meta "google" {
module_name = "blueprints/terraform/terraform-google-bootstrap:tf_cloudbuild_workspace/v7.0.0"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
module_name = "blueprints/terraform/terraform-google-bootstrap:tf_cloudbuild_workspace/v7.0.0"
module_name = "blueprints/terraform/terraform-google-bootstrap:im_cloudbuild_workspace/v7.0.0"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated, although is there any issues with any versioning here given this is unreleased at the moment?

Copy link
Member

Choose a reason for hiding this comment

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

The versioning should be okay, our release tooling should bump the version string in next release PR

Comment on lines 36 to 38
secretEnv: ['IM_GITHUB_PAT']
env:
- 'TF_VAR_im_github_pat_secret=$_IM_GITHUB_PAT_SECRET_ID'
Copy link
Member

Choose a reason for hiding this comment

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

nit: I think this is unnecessary

Copy link
Collaborator Author

@josephdt12 josephdt12 Mar 11, 2024

Choose a reason for hiding this comment

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

Currently following the example here which sets up a similar secret to be used here https://github.com/GoogleCloudPlatform/terraform-google-tf-cloud-agents/blob/main/build/int.cloudbuild.yaml#L156.

Would the TF_VAR setup be preferred instead? I think I'd need to add the variable to the variables.tf in the setup folder? And then update the YAML and example to use that accordingly?

Currently, it sets the ENV variable using that secret which is used by the integration test file which sets the variable used by the example.

Copy link
Member

Choose a reason for hiding this comment

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

In this case it was just a nit that this init step wont care about the env var so we could skip it

Example and minimum version set to the minimum IM version.
Prevents issue with creating multiple triggers for a repository (maybe
dependent upon different branches).
Trims the top line and counts how many lines are present.
Should only be 1 line corresponding to a single deployment.
Was previously added to be used by the integration test, replaced with
hard-coded values.
Following better practices for IAM resources
* Style issues
* Removed explicit trigger name checks as those have random IDs added.
  The IDs are used directly for checking if they ran, so still checking
  that behavior
* Added clean up step to clean up the old deployment rather than leaving
  it for project clean up
Currently using the secret manager setup
@bharathkkb bharathkkb marked this pull request as ready for review March 11, 2024 22:08
@bharathkkb bharathkkb requested a review from a team as a code owner March 11, 2024 22:08
@bharathkkb bharathkkb enabled auto-merge (squash) March 11, 2024 22:49
Utilizes the GitHub API to create a repository on demand, and delete it
after teardown.
auto-merge was automatically disabled March 12, 2024 01:23

Head branch was pushed to by a user without write access

Should help deal with IAM propagation delay, similar to the other
service accounts being checked for a specific role.
They don't contain sensitive values themselves, and might just be the
linter reacting to the variable names. But I could see why a secret_id
might want to be labeled as sensitive as well.
@bharathkkb bharathkkb merged commit 61ec4eb into terraform-google-modules:master Mar 12, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants