Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

chore(codebuild): Login to dockerhub #72

Merged
merged 1 commit into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ phases:
- echo "running for ${COMMIT_SHA} in ${DEPLOY_ENV}"
- aws eks update-kubeconfig --name $CLUSTER
- aws ecr get-login --region us-west-2 --no-include-email | bash
- echo $DOCKERHUB_PASSWORD | docker login -u $DOCKERHUB_USERNAME --pasword-stdin
build:
commands:
- if [ "$PR" = 1 ]; then myke docker; fi
Expand Down
22 changes: 22 additions & 0 deletions terraform/codebuild/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,19 @@ resource "aws_codebuild_project" "build" {
name = "DOCKER_REPO"
value = aws_ecr_repository.registry.repository_url
}

environment_variable {
name = "DOCKERHUB_USERNAME"
type = "SECRETS_MANAGER"
value = "/CodeBuild/dockerhub:username"
}

environment_variable {
name = "DOCKERHUB_PASSWORD"
type = "SECRETS_MANAGER"
value = "/CodeBuild/dockerhub:password"
}

}

source {
Expand Down Expand Up @@ -115,6 +128,15 @@ resource "aws_iam_role_policy" "codebuild" {
"eks:DescribeCluster"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Resource": [
"arn:aws:secretsmanager:*:*:secret:/CodeBuild/dockerhub*"
],
"Action": [
"secretsmanager:GetSecretValue"
]
}
]
}
Expand Down