Skip to content

Commit

Permalink
update oidc branch based on a simplified ecs module
Browse files Browse the repository at this point in the history
  • Loading branch information
alismx committed Sep 3, 2024
1 parent 768cf52 commit 5d1250f
Show file tree
Hide file tree
Showing 8 changed files with 381 additions and 129 deletions.
126 changes: 0 additions & 126 deletions terraform/implementation/setup/iam.tf

This file was deleted.

15 changes: 13 additions & 2 deletions terraform/implementation/setup/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@ provider "aws" {
}
}

# GitHub OIDC for prod
module "oidc" {
source = "../../modules/oidc"

oidc_github_repo = var.oidc_github_repo
owner = var.owner
project = var.project
region = var.region
workspace = "prod"
}

resource "random_string" "setup" {
length = 8
special = false
Expand Down Expand Up @@ -69,7 +80,7 @@ resource "local_file" "setup_env" {
BUCKET="${aws_s3_bucket.tfstate.bucket}"
DYNAMODB_TABLE="${aws_dynamodb_table.tfstate_lock.id}"
REGION="${var.region}"
TERRAFORM_ROLE="${aws_iam_role.github.arn}"
TERRAFORM_ROLE="${module.oidc.role.arn}"
EOT
filename = ".env"
}
Expand All @@ -79,7 +90,7 @@ resource "local_file" "ecs_env" {
BUCKET="${aws_s3_bucket.tfstate.bucket}"
DYNAMODB_TABLE="${aws_dynamodb_table.tfstate_lock.id}"
REGION="${var.region}"
TERRAFORM_ROLE="${aws_iam_role.github.arn}"
TERRAFORM_ROLE="${module.oidc.role.arn}"
EOT
filename = "../ecs/.env"
}
2 changes: 1 addition & 1 deletion terraform/implementation/setup/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if ! grep -q "region" "$WORKSPACE.tfvars"; then
fi

if ! grep -q "oidc_github_repo" "$WORKSPACE.tfvars"; then
read -p "Are you using GitHub for your source control? (y/n): " github_choice
read -p "Do you want to setup a GitHub IODC role? (y/n): " github_choice
if [[ "$github_choice" =~ ^[Yy]$ ]]; then
read -p "What is the organization/repo value for assume role? ( default=\"\" ): " repo_choice
repo_choice=${repo_choice:-""}
Expand Down
Loading

0 comments on commit 5d1250f

Please sign in to comment.