-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Putting GITHUB_TOKEN in terraform config for aws_codepipeline #2796
Comments
Ran across this as I'm working with the resource in question. (Edited as I was previously mistaken about the level of access CodePipeline requires) If you're working with private repos, CodePipeline requires that the token you give it have access to those private repositories. As such, it's not great to encourage users to check those tokens in to source control along with their config, or leak it into state. I gather some other providers (RDS for example) can encrypt their inputs in state, and with a big warning around the feature to remember to keep secrets in local config overrides and not in source it might be ok. But it does seem a little risky. Basically, it would need to be treated like other secrets, such as the access key id and secret in the AWS provider. |
Absolutely. It is an issue? |
@yacinehmito wow, this is ridiculous that I need to set the env variable!!! there is a config field for Can this be fixed somehow? I mean I have a separate CodeBuild project (non-pipeline) where I use a Personal Access Token, and it all works. Why can't it work through pipeline? Is this a terraform issue or AWS CLI issue? |
the precise code I meant in my earlier comment is like below. I store the PAT in SSM, so that it's easy to access and it is the same, no matter which developer is running
|
I see it in the code: https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/resource_aws_codepipeline.go#L284-L291 But why in heavens do this? What is the rationale behind it? This isn't the case for CodeBuild projects. @stack72 @comebackoneyear Could either of you provide some background as to why this was coded this way? Any warnings/objections to changing it, so that one could use something like this?
|
@yacinehmito @stack72 @comebackoneyear Bumping this. I'd like to get a resolution on this, and perhaps do a PR (though I haven't written a line of Go in my life). I honestly think that we should not use an ENV var, because that does not prevent the token from being stored in the state. It is displayed in the plan, regardless of the way it is specified. That is a separate issue. I currently mitigate it by storing state on encrypted S3 bucket. |
I'll have to back down on this, sorry. I don't have this need anymore. (And I haven't written a line of Go in my life either). Still interested in having this solved for the sake of it though. |
… in hashicorp#2796. This simply removes the code that deletes the token passed in and arbitrary validation condition looking for GITHUB_TOKEN env variable. This is behavior goes against Terraform convention, and is absolutely NOT documented, and there was no rationale provided. A much better way to address this is to improve the schema of the in the project definition to mark OAuthToken as sensitive.
@yacinehmito I made a PR. I removed the frustrating code, but I kept the code that allows setting the value from ENV var. I am beginning to realie that this was an early hack to prevent it from being displayed. A much better way to hide the value of the token is to polish off the schema to mark it as sensitive. |
I'm using atlantis in Fargate, which also requires a github token. I use chamber to fetch the token at runtime: It's a wrapper for SSM Parameter Store. the This way you don't have to commit your token in git and it also won't appear in your terraform or CI output |
would the personal access token do ? |
The AWS CodeBuild resource does not require this and works nicely using the OAUTH already granted to CodeBuild through the UI. Can something similar be done here? Requiring this to be present in ENV VAR is pretty problematic, especially during development where a developer might not have this. |
This is a bummer. Just ran into this. I liked how CodeBuild did this. Just need to walk through the connection via the GUI once, then reuse. |
Ran into this issue today. I have a I've stored the token for CodePipeline in AWS SecretsManager, and was trying to set the Can someone remove this? Seems like this issue has been open here for a while already. The state already stores database passwords and other sensitive information, so it should not be an issue for the state to store this token. If anything it should just be marked as sensitive so it doesn't print out in plan. Those concerned about keeping secrets in the state should seriously consider using remote states |
Would be great if we could just use the solution proposed by psteininger
I also was under the impression the OAuthToken configuration parameter would work as expected in CodePipeline. |
I have a similar use case as @yogin Assuming if I had ReasonsI think it's incorrect to overwrite the original
ProposalsTo solve these issues I have 2 proposals:
or
Edit: |
While removing the ability to reference the I can easily imagine a situation where a user didn't set the oauth token in terraform and then terraform then pulls it from the environment variable automatically causing much confusion. The oauth token should be set just like any other sensitive parameter is set:
|
This has been released in version 3.0.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
When using AWS CodePipeline, if you want to fetch your source code from GitHub, you need to run
terraform apply
with the environment variableGITHUB_TOKEN
(whose value should be a previously generated OAuth token).This kinda goes against Terraform's philosophy. Would it be more sensible to have a parameter for the resource
aws_codepipeline
to set that token? Is there a compelling reason to use an environment variable instead?I'm starting the discussion. If we end up deciding on a parameter I'm willing to have a go at a PR.
The text was updated successfully, but these errors were encountered: