Skip to content

Commit

Permalink
Add custom slack channel id to image build project
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnStainsby committed Jan 31, 2025
1 parent 604a1da commit cafcef3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
1 change: 0 additions & 1 deletion codebase-pipelines/buildspec-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ version: 0.2

env:
parameter-store:
SLACK_CHANNEL_ID: /codebuild/slack_oauth_channel
SLACK_TOKEN: /codebuild/slack_oauth_token

phases:
Expand Down
6 changes: 6 additions & 0 deletions codebase-pipelines/codebuild.tf
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ resource "aws_codebuild_project" "codebase_image_build" {
value = data.aws_codestarconnections_connection.github_codestar_connection.arn
}

environment_variable {
name = "SLACK_CHANNEL_ID"
value = var.slack_channel
type = "PARAMETER_STORE"
}

dynamic "environment_variable" {
for_each = var.additional_ecr_repository != null ? [1] : []
content {
Expand Down
12 changes: 10 additions & 2 deletions codebase-pipelines/tests/unit.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,19 @@ run "test_codebuild_images" {
error_message = "Should be: 'my-app/my-codebase'"
}
assert {
condition = one(aws_codebuild_project.codebase_image_build[""].environment).environment_variable[3].name == "ADDITIONAL_ECR_REPOSITORY"
condition = one(aws_codebuild_project.codebase_image_build[""].environment).environment_variable[3].name == "SLACK_CHANNEL_ID"
error_message = "Should be: 'SLACK_CHANNEL_ID'"
}
assert {
condition = one(aws_codebuild_project.codebase_image_build[""].environment).environment_variable[3].value == "/fake/slack/channel"
error_message = "Should be: '/fake/slack/channel'"
}
assert {
condition = one(aws_codebuild_project.codebase_image_build[""].environment).environment_variable[4].name == "ADDITIONAL_ECR_REPOSITORY"
error_message = "Should be: 'ADDITIONAL_ECR_REPOSITORY'"
}
assert {
condition = one(aws_codebuild_project.codebase_image_build[""].environment).environment_variable[3].value == "my-additional-repository"
condition = one(aws_codebuild_project.codebase_image_build[""].environment).environment_variable[4].value == "my-additional-repository"
error_message = "Should be: 'my-additional-repository'"
}
assert {
Expand Down

0 comments on commit cafcef3

Please sign in to comment.