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

update module to reduce the number of arguments needed to use it #17

Merged
merged 1 commit into from
Sep 5, 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
126 changes: 0 additions & 126 deletions terraform/implementation/setup/iam.tf

This file was deleted.

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

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

# The github repo that will be used for OIDC
oidc_github_repo = var.oidc_github_repo

# These variables must match the values that you'll be using for your ECS module call in the /ecs module
region = var.region
owner = var.owner
project = var.project

# This variable must match the name of the terraform workspace that you'll be using for your ECS module call in the /ecs module
workspace = "prod"

state_bucket_arn = aws_s3_bucket.tfstate.arn
dynamodb_table_arn = aws_dynamodb_table.tfstate_lock.arn
}

resource "random_string" "setup" {
length = 8
special = false
Expand Down Expand Up @@ -69,7 +88,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 +98,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