Skip to content

Commit

Permalink
[+] policy_arn_attachments option added
Browse files Browse the repository at this point in the history
  • Loading branch information
g31s committed Feb 4, 2022
1 parent 4a959c5 commit 76662fa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ More examples: [Examples](./examples/)
| max_app_count | N | 10 | number | - | 100 |
| extra_ports | N | [] | list(string) | Open extra port in task definition | ["443","542"] |
| secrets | N | [] | list(object) | Will add IAM permissions and secrets to task definition | [aws_secretsmanager_secret.main.usernamer,aws_secretsmanager_secret.main.password]|
| policy_arn_attachments | N | [] | list(string) | can provide addition policies arns to be attached to ecs roles | [arn:aws:iam::aws:policy/service-role/AWSLambdaDynamoDBExecutionRole] |
| aws_appmesh_virtual_node | N | "none" | string | virtual node or virtual gateway must be present|aws_appmesh_virtual_node.main.name |
| virtual_gateway | N | "none" | string | virtual node or virtual gateway must be present|"test_virtual_gateway" |
| envoy_proxy_image | N |"840364872350.dkr.ecr.us-east-1.amazonaws.com/aws-appmesh-envoy:v1.15.1.0-prod"|string|work for all regions except: me-south-1, ap-east-1, and eu-south-1 |me-south-1 : "772975370895.dkr.ecr.me-south-1.amazonaws.com/aws-appmesh-envoy:v1.15.1.0-prod" |
Expand Down
11 changes: 9 additions & 2 deletions roles.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Module: ECS-Fargate-Appmesh
Version: 1.0.0
Version: 1.2.7
This file will create:
- IAM policy: to allow ecs tasks to assume role
Expand Down Expand Up @@ -55,4 +55,11 @@ resource "aws_iam_role_policy_attachment" "sm-policy-attach" {
count = length(var.secrets) == 0 ? 0 : 1
role = aws_iam_role.ecs_task_execution_role.name
policy_arn = "arn:aws:iam::aws:policy/SecretsManagerReadWrite"
}
}

// add module provided policies
resource "aws_iam_role_policy_attachment" "module-provided-policies" {
count = length(var.policy_arn_attachments) == 0 ? 0 : length(var.policy_arn_attachments)
role = aws_iam_role.ecs_task_execution_role.name
policy_arn = count.index
}
10 changes: 8 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Module: ECS-Fargate-APPMESH
Version: 1.0.0
Version: 1.2.7
This file defines all the variables for this module.
Variables are divided into two sections:
Expand Down Expand Up @@ -55,7 +55,13 @@ variable "vpc" {
variable "prefix" {
type = string
description = "project prefix added to all resources created"
default = "EFA"
default = "EFA"
}

variable "policy_arn_attachments" {
type = list(string)
description = "list of policies that needs to be attached"
default = []
}

// app variables
Expand Down

0 comments on commit 76662fa

Please sign in to comment.