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: adding tests for the major submodules #3

Merged
merged 36 commits into from
Aug 24, 2023

Conversation

gautambaghel
Copy link
Contributor

FYI: This won't work without a Terraform cloud org name and a token

@gautambaghel gautambaghel requested a review from a team as a code owner August 11, 2023 22:15
@gautambaghel gautambaghel changed the title feat: Adding tests for the major submodules chore(main): Adding tests for the major submodules Aug 11, 2023
@g-awmalik
Copy link
Collaborator

/gcbrun

@g-awmalik
Copy link
Collaborator

g-awmalik commented Aug 15, 2023

@gautambaghel - take a look at these errors from the int test run: https://gist.github.com/g-awmalik/813e6b8a277dd8f7f9d84dec4230e6dc

It seems like you're not setting the TFC org name & the image name in the examples.

@g-awmalik
Copy link
Collaborator

@gautambaghel - take a look at these errors from the int test run: https://gist.github.com/g-awmalik/813e6b8a277dd8f7f9d84dec4230e6dc

It seems like you're not setting the TFC org name & the image name in the examples.

There are a couple of ways we can do this:

  • you can create an output for the TFE org id and the image name here. These outputs are exported as env vars and are available to the examples. This is also how the gcp project id variable is set.
  • Or you can set them directly in the example (non recommended since you'll end up setting the same ID multiple times across multiple exampled.

@gautambaghel
Copy link
Contributor Author

@g-awmalik - This is expected, we need to pass the TFC token and TFC org name somehow...

The custom image however needs to be resolved, is there a way to create the image via the Cloudbuild pipeline? It's taken from the GH pipeline repo here -> https://github.com/terraform-google-modules/terraform-google-github-actions-runners/tree/master/examples/gh-runner-mig-native-packer

I need to know from Bharath how he tests these...

@gautambaghel
Copy link
Contributor Author

@g-awmalik - We'll do the first approach you recommended, it seems doable but it still won't work if the TFC login token is not present on the machine (because the TFE provider needs that)

  • you can create an output for the TFE org id and the image name here. These outputs are exported as env vars and are available to the examples. This is also how the gcp project id variable is set.

@gautambaghel
Copy link
Contributor Author

These tests should run perfectly fine with a free Terraform Cloud account so if Google wants to create one and have complete ownership of it for security purposes I'm fine with it.

@g-awmalik
Copy link
Collaborator

@g-awmalik - This is expected, we need to pass the TFC token and TFC org name somehow...

The custom image however needs to be resolved, is there a way to create the image via the Cloudbuild pipeline? It's taken from the GH pipeline repo here -> https://github.com/terraform-google-modules/terraform-google-github-actions-runners/tree/master/examples/gh-runner-mig-native-packer

I need to know from Bharath how he tests these...

I didn't realize the TFC token was part of this PR. For that we can use secrets with cloud build. Basically, you can set up the token and I'll put that in Secrets Manager in our CI/CD GCP that only the CI/CD service account will have access to. You'll just need to get it as an env var in the go test.

However, TFC org name and image can still be set up as outputs since there's nothing sensitive there unless I'm mistaken. Let me know.

@g-awmalik
Copy link
Collaborator

@g-awmalik - This is expected, we need to pass the TFC token and TFC org name somehow...

The custom image however needs to be resolved, is there a way to create the image via the Cloudbuild pipeline? It's taken from the GH pipeline repo here -> https://github.com/terraform-google-modules/terraform-google-github-actions-runners/tree/master/examples/gh-runner-mig-native-packer

I need to know from Bharath how he tests these...

Take a look at building images with cloud build. Basically, you'll need to add after prepare where you can build the image and then set the name as an env var with a TF_VAR_ prefix for the examples to pick it up.

@gautambaghel
Copy link
Contributor Author

@g-awmalik - Added the fixes in the new commit, two things that need to be done before the tests work

  • Put the TFC token and put that in Secrets Manager in the CI/CD
  • The Cloud build pipeline service account that runs the integration tests needs to have Compute Instance Admin (v1) & Service Account User roles for the images to be created

Thanks!

The TFE_TOKEN secret can be used in relevant steps as:

steps:
- name: STEP_NAME
  ...
  secretEnv: ['TFE_TOKEN']
  ...
@g-awmalik
Copy link
Collaborator

@gautambaghel - the secret should be available in cloud build as an env var as soon as GoogleCloudPlatform/cloud-foundation-toolkit#1782 is applied.

@gautambaghel
Copy link
Contributor Author

I think it's merged can you do a /gcbrun please? thx!

@g-awmalik
Copy link
Collaborator

/gcbrun

@g-awmalik
Copy link
Collaborator

/gcbrun

@g-awmalik
Copy link
Collaborator

/gcbrun

@g-awmalik
Copy link
Collaborator

/gcbrun

@g-awmalik
Copy link
Collaborator

/gcbrun

@g-awmalik
Copy link
Collaborator

/gcbrun

@g-awmalik
Copy link
Collaborator

/gcbrun

@g-awmalik
Copy link
Collaborator

/gcbrun

@g-awmalik
Copy link
Collaborator

/gcbrun

@g-awmalik
Copy link
Collaborator

/gcbrun

@g-awmalik
Copy link
Collaborator

/gcbrun

1 similar comment
@g-awmalik
Copy link
Collaborator

/gcbrun

@g-awmalik
Copy link
Collaborator

/gcbrun

1 similar comment
@g-awmalik
Copy link
Collaborator

/gcbrun

@g-awmalik
Copy link
Collaborator

/gcbrun

1 similar comment
@g-awmalik
Copy link
Collaborator

/gcbrun

@g-awmalik
Copy link
Collaborator

/gcbrun

@g-awmalik
Copy link
Collaborator

/gcbrun

@g-awmalik
Copy link
Collaborator

/gcbrun

1 similar comment
@g-awmalik
Copy link
Collaborator

/gcbrun

@g-awmalik g-awmalik merged commit 330969f into GoogleCloudPlatform:main Aug 24, 2023
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