Skip to content
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
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ jobs:
runs-on: ubuntu-latest
container:
image: hashicorp/terraform:1.5.7
env:
TF_PLUGIN_CACHE_DIR: /github/home/.terraform.d/plugin-cache
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create Plugin Cache Dir
run: mkdir -p $TF_PLUGIN_CACHE_DIR
- name: Check format
run: terraform fmt -diff=true -check=true
- name: Validate
Expand Down
12 changes: 12 additions & 0 deletions eks-service-account-iam-role/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ data "aws_iam_policy_document" "assume_role" {
values = local.all_service_accounts
}
}

dynamic "statement" {
for_each = length(var.trusted_role_arns) > 0 ? [1] : []
content {
effect = "Allow"
principals {
type = "AWS"
identifiers = var.trusted_role_arns
}
actions = ["sts:AssumeRole"]
}
}
}

resource "aws_iam_role_policy" "main" {
Expand Down
6 changes: 6 additions & 0 deletions eks-service-account-iam-role/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,9 @@ variable "add_policy" {
variable "id" {
default = ""
}

variable "trusted_role_arns" {
type = list(string)
description = "List of AWS IAM Role ARNs that can assume this role"
default = []
}
1 change: 1 addition & 0 deletions validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ for dir in $dirs; do
cd $dir
terraform init
terraform validate
rm -rf .terraform
cd - > /dev/null
done