ghe-key.tf 1.1 KB

123456789101112131415161718192021222324252627
  1. data "aws_secretsmanager_secret" "ghe-key" {
  2. name = "GHE/mdr-aws-codebuild/key"
  3. provider = aws.c2
  4. }
  5. data "aws_secretsmanager_secret_version" "ghe-key" {
  6. secret_id = data.aws_secretsmanager_secret.ghe-key.id
  7. provider = aws.c2
  8. }
  9. #locals {
  10. # If key was in json format, we would need to decode it.
  11. # secret_ghe_key = jsondecode(data.aws_secretsmanager_secret_version.ghe-key.secret_string)
  12. #}
  13. # Note some AWS craziness here. The GitHub credential is not tied to a build, even though it _looks_
  14. # like it is in the Web UI. There can only be one GitHub credential per account+region::
  15. # https://docs.aws.amazon.com/cdk/api/v1/docs/@aws-cdk_aws-codebuild.GitHubSourceCredentials.html
  16. #
  17. # "Note: CodeBuild only allows a single credential for GitHub to be saved in a given AWS account
  18. # in a given region - any attempt to add more than one will result in an error."
  19. resource "aws_codebuild_source_credential" "github_token" {
  20. auth_type = "PERSONAL_ACCESS_TOKEN"
  21. server_type = "GITHUB_ENTERPRISE"
  22. token = data.aws_secretsmanager_secret_version.ghe-key.secret_string
  23. }