-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
313 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# Modules/Services/NWP | ||
# Modules/Services/nwp_consumer | ||
|
||
This module makes | ||
- AWS task definition | ||
- IAM role to setup application | ||
- IAM role for running task | ||
- get secrets for NWP API | ||
- temp: scheduled aws task, and iam roles | ||
- AWS ECS Task Definition, with: | ||
- S3 and SecretsManager access | ||
- AWS CloudWatch Logs group | ||
- IAM role to create the ECS Task | ||
- IAM role to run the ECS Task |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
# Read in required secrets for consumer | ||
# Get the secret resource from AWS for each entry in the list | ||
# Access a secret in secrets manager | ||
# 1. Gets the id of current version of the secret | ||
# 2. Creates a policy to allow read access to the secret | ||
|
||
# Read in required secret for task | ||
data "aws_secretsmanager_secret" "secret" { | ||
name = var.aws_config.secretsmanager_secret_name | ||
name = var.aws-secretsmanager_secret_name | ||
} | ||
|
||
# Get the current secret value from AWS for the secret | ||
# 1. Get the current secret value from AWS for the secret | ||
data "aws_secretsmanager_secret_version" "current" { | ||
secret_id = data.aws_secretsmanager_secret.secret.id | ||
} | ||
|
||
# Get an IAM role to access the secret | ||
# Create a policy enabling read access to secrets | ||
data "aws_iam_policy_document" "secret_read_policy" { | ||
statement { | ||
version = "2012-10-17" | ||
actions = [ | ||
"secretsmanager:ListSecretVersionIds", | ||
"secretsmanager:GetSecretValue", | ||
] | ||
effect = "Allow" | ||
resources = [ | ||
data.aws_secretsmanager_secret_version.current.arn, | ||
] | ||
} | ||
} | ||
|
||
# 2. Create an IAM policy to access the current version of the secret | ||
resource "aws_iam_policy" "secret_read_policy" { | ||
name = "${var.app_name}-secret-read-policy" | ||
path = "/consumer/nwp/" | ||
name = "${var.ecs-task_name}-secret-read-policy" | ||
path = "/${var.ecs-task_type}/${var.ecs-task_name}/" | ||
description = "Policy to allow read access to secret." | ||
|
||
policy = jsonencode({ | ||
Version = "2012-10-17" | ||
Statement = [ | ||
{ | ||
Action = [ | ||
"secretsmanager:ListSecretVersionIds", | ||
"secretsmanager:GetSecretValue", | ||
] | ||
Effect = "Allow" | ||
Resource = data.aws_secretsmanager_secret_version.current.arn | ||
}, | ||
] | ||
}) | ||
policy = data.aws_iam_policy_document.secret_read_policy.json | ||
} | ||
|
Oops, something went wrong.