Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: create Forms API OIDC role for releases #830

Merged
merged 1 commit into from
Sep 16, 2024
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
14 changes: 11 additions & 3 deletions aws/oidc_roles/iam_policies.tf
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,21 @@ data "aws_iam_policy_document" "platform_forms_client_pr_review_env" {
#
# Push and manage ECR images
#
resource "aws_iam_policy" "forms_api_release" {
count = var.env == "production" ? 1 : 0
name = local.forms_api_release
path = "/"
policy = data.aws_iam_policy_document.ecr_push_image[0].json
}

resource "aws_iam_policy" "platform_forms_client_release" {
count = var.env == "production" ? 1 : 0
name = local.platform_forms_client_release
path = "/"
policy = data.aws_iam_policy_document.platform_forms_client_release[0].json
policy = data.aws_iam_policy_document.ecr_push_image[0].json
}

data "aws_iam_policy_document" "platform_forms_client_release" {
data "aws_iam_policy_document" "ecr_push_image" {
count = var.env == "production" ? 1 : 0

statement {
Expand All @@ -142,7 +149,8 @@ data "aws_iam_policy_document" "platform_forms_client_release" {
"ecr:UploadLayerPart"
]
resources = [
"arn:aws:ecr:${var.region}:${var.account_id}:repository/form_viewer_production"
"arn:aws:ecr:${var.region}:${var.account_id}:repository/form_viewer_production",
"arn:aws:ecr:${var.region}:${var.account_id}:repository/forms/api"
]
}

Expand Down
15 changes: 15 additions & 0 deletions aws/oidc_roles/iam_roles.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
locals {
forms_api_release = "forms-api-release"
platform_forms_client_pr_review_env = "platform-forms-client-pr-review-env"
platform_forms_client_release = "platform-forms-client-release"
}
Expand All @@ -20,6 +21,11 @@ module "github_workflow_roles" {
source = "github.com/cds-snc/terraform-modules//gh_oidc_role?ref=dca686fdd6670f0b3625bc17a5661bec3ea5aa62" #v9.0.3
billing_tag_value = var.billing_tag_value
roles = [
{
name = local.forms_api_release
repo_name = "forms-api"
claim = "ref:refs/tags/v*"
},
{
name = local.platform_forms_client_pr_review_env
repo_name = "platform-forms-client"
Expand All @@ -37,6 +43,15 @@ module "github_workflow_roles" {
# Attach polices to the OIDC roles to grant them permissions. These
# attachments are scoped to only the environments that require the role.
#
resource "aws_iam_role_policy_attachment" "forms_api_release" {
count = var.env == "production" ? 1 : 0
role = local.forms_api_release
policy_arn = aws_iam_policy.forms_api_release[0].arn
depends_on = [
module.github_workflow_roles
]
}

resource "aws_iam_role_policy_attachment" "platform_forms_client_pr_review_env" {
count = var.env == "staging" ? 1 : 0
role = local.platform_forms_client_pr_review_env
Expand Down
Loading