hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.87k stars 9.21k forks source link

[Enhancement]: Allow CodeBuild Source Credentials Resource to leverage Secrets Manager/Parameter Store #29972

Open stevebott opened 1 year ago

stevebott commented 1 year ago

Description

Allow CodeBuild Source Credentials Resource (aws_codebuild_source_credential) to leverage Secrets Manager or Parameter Store for the token, vs. requiring the token to be stored in the terraform code as plain text.

Affected Resource(s) and/or Data Source(s)

Potential Terraform Configuration

resource "aws_codebuild_source_credential" "secret-example" {
  auth_type   = "PERSONAL_ACCESS_TOKEN"
  server_type = "GITHUB"
  token       = {
    value = "arn:aws:secretsmanager:<region>:<account>:secret:github-secrets:access-token"
    type  = "SECRETS_MANAGER"
  }

resource "aws_codebuild_source_credential" "parameter-example" {
  auth_type   = "PERSONAL_ACCESS_TOKEN"
  server_type = "GITHUB"
  token       = {
    value = "arn:aws:ssm:<region>:<account>:parameter/github/access-tokenS"
    type  = "PARAMETER_STORE"
  }

resource "aws_codebuild_source_credential" "plain-example-full" {
  auth_type   = "PERSONAL_ACCESS_TOKEN"
  server_type = "GITHUB"
  token       = {
    value = "xxxxxxxxxxxxxxxxxxxxxxxxxx"
    type  = "PLAINTEXT"
  }

resource "aws_codebuild_source_credential" "plain-example-minimal" {
  auth_type   = "PERSONAL_ACCESS_TOKEN"
  server_type = "GITHUB"
  token       = "xxxxxxxxxxxxxxxxxxxxxxxxxx"
}

References

No response

Would you like to implement a fix?

No

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

DrFaust92 commented 1 year ago

This is not currently supported by AWS API https://docs.aws.amazon.com/codebuild/latest/APIReference/API_ImportSourceCredentials.html

terenho commented 5 days ago

It seems to be supported now. I can do

resource "aws_codebuild_source_credential" "secret-example" {
  auth_type   = "SECRETS_MANAGER"
  server_type = "GITHUB"
  token       = "arn:aws:secretsmanager:<region>:<account>:secret:github-secrets-XXXXXX"
}

https://docs.aws.amazon.com/codebuild/latest/APIReference/API_ImportSourceCredentials.html also mentions we can put secrets manager arn as the token