Skip to content

Commit

Permalink
SSM parameter for GCP SRE service account credentials. (#443)
Browse files Browse the repository at this point in the history
* Adding a new SSM parameter for the gcp google service account file crednetials

* Adding the secret in the task definition file
  • Loading branch information
sylviamclaughlin authored Apr 9, 2024
1 parent 5d4fb3f commit ec5fd3a
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/tf_apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ env:
TERRAGRUNT_VERSION: 0.31.1
TF_VAR_google_oauth_pickle_string: "${{ secrets.GOOGLE_PICKLE_STRING }}"
TF_VAR_slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
TF_VAR_gcp_sre_service_account_key: ${{ secrets.GCP_SRE_SERVICE_ACCOUNT_KEY_FILE }}



permissions:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tf_plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ env:
TERRAGRUNT_VERSION: 0.31.1
TF_VAR_google_oauth_pickle_string: "${{ secrets.GOOGLE_PICKLE_STRING }}"
TF_VAR_slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
TF_VAR_gcp_sre_service_account_key: ${{ secrets.GCP_SRE_SERVICE_ACCOUNT_KEY_FILE }}


permissions:
Expand Down
5 changes: 4 additions & 1 deletion app/pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ env =
ATIP_ANNOUNCE_CHANNEL = "ATIP_ANNOUNCE_CHANNEL"
TRELLO_APP_KEY = "TRELLO_APP_KEY"
TRELLO_TOKEN = "TRELLO_TOKEN"
TRELLO_ATIP_BOARD = "TRELLO_ATIP_BOARD"
TRELLO_ATIP_BOARD = "TRELLO_ATIP_BOARD"
GCP_SRE_SERVICE_ACCOUNT_KEY_FILE = "GCP_SRE_SERVICE_ACCOUNT_KEY_FILE"


17 changes: 9 additions & 8 deletions terraform/ecs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ data "template_file" "sre-bot" {
template = file("./templates/sre-bot.json.tpl")

vars = {
awslogs-group = aws_cloudwatch_log_group.sre-bot_group.name
awslogs-region = "ca-central-1"
awslogs-stream-prefix = "ecs-sre-bot"
image = "${aws_ecr_repository.sre-bot.repository_url}:latest"
fargate_cpu = var.fargate_cpu
fargate_memory = var.fargate_memory
aws_region = "ca-central-1"
PICKLE_STRING = aws_ssm_parameter.google_oauth_pickle_string.arn
awslogs-group = aws_cloudwatch_log_group.sre-bot_group.name
awslogs-region = "ca-central-1"
awslogs-stream-prefix = "ecs-sre-bot"
image = "${aws_ecr_repository.sre-bot.repository_url}:latest"
fargate_cpu = var.fargate_cpu
fargate_memory = var.fargate_memory
aws_region = "ca-central-1"
PICKLE_STRING = aws_ssm_parameter.google_oauth_pickle_string.arn
GCP_SRE_SERVICE_ACCOUNT_KEY_FILE = aws_ssm_parameter.gcp_sre_service_account_key.arn
}
}

Expand Down
3 changes: 2 additions & 1 deletion terraform/iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ data "aws_iam_policy_document" "sre-bot_secrets_manager" {
]
resources = [
"arn:aws:ssm:ca-central-1:${data.aws_caller_identity.current.account_id}:parameter/sre-bot-config",
aws_ssm_parameter.google_oauth_pickle_string.arn
aws_ssm_parameter.google_oauth_pickle_string.arn,
aws_ssm_parameter.gcp_sre_service_account_key.arn
]
}

Expand Down
13 changes: 12 additions & 1 deletion terraform/ssm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,15 @@ resource "aws_ssm_parameter" "google_oauth_pickle_string" {
CostCentre = var.billing_code
Terraform = true
}
}
}

resource "aws_ssm_parameter" "gcp_sre_service_account_key" {
name = "gcp_sre_service_account_key"
type = "SecureString"
value = var.gcp_sre_service_account_key

tags = {
CostCentre = var.billing_code
Terraform = true
}
}
4 changes: 4 additions & 0 deletions terraform/templates/sre-bot.json.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
{
"name": "PICKLE_STRING",
"valueFrom": "${PICKLE_STRING}"
},
{
"name": "GCP_SRE_SERVICE_ACCOUNT_KEY_FILE",
"valueFrom": "${GCP_SRE_SERVICE_ACCOUNT_KEY_FILE}"
}
],
"ulimits": [
Expand Down
6 changes: 6 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ variable "google_oauth_pickle_string" {
sensitive = true
}

variable "gcp_sre_service_account_key" {
description = "(Required) The GCP SRE service account key"
type = string
sensitive = true
}

variable "error_threshold" {
description = "CloudWatch alarm threshold for the SRE Bot ERROR logs"
type = string
Expand Down

0 comments on commit ec5fd3a

Please sign in to comment.