lgallard / terraform-aws-secrets-manager

Terraform module to create Amazon Secrets Manager resources.
Apache License 2.0
64 stars 50 forks source link

Validation error on secrets in module #47

Open lucasleys opened 10 months ago

lucasleys commented 10 months ago

Locally, i don't get any validation errors. When i try running it in a gitlab pipeline it gives me validation errors. Computing.tf

---ECS---

data "aws_iam_role" "labrole" { name = "LabRole" }

resource "aws_ecs_cluster" "ecs_cluster_j1" { name = "ecs-cluster-j1" }

resource "aws_ecs_service" "service_j1" { name = "ecs-service-j1" cluster = aws_ecs_cluster.ecs_cluster_j1.id task_definition = aws_ecs_task_definition.task_j1.arn desired_count = 4 launch_type = "FARGATE"

load_balancer { target_group_arn = aws_lb_target_group.alb_ecs_tg_j1.arn container_name = "j1-container" container_port = 80 }

network_configuration {

assign_public_ip = true

subnets = [module.vpc.private_subnets[0], module.vpc.private_subnets[1]] security_groups = [aws_security_group.sg2-j1.id] }

depends_on = [aws_ecs_cluster.ecs_cluster_j1 , aws_ecs_task_definition.task_j1, aws_security_group.sg2-j1] }

resource "aws_ecs_task_definition" "task_j1" { family = "task-family" network_mode = "awsvpc" requires_compatibilities = ["FARGATE"] cpu = "256" memory = "512" execution_role_arn = data.aws_iam_role.labrole.arn

container_definitions = jsonencode([ { name = "j1-container" image = "" // Replace with your Docker image repositoryCredentials: { credentialsParameter: values(module.secrets-manager-2.secret_arns)[0] } environment: [ { "name": "WEB_HOST", "value": "http://${aws_lb.alb-j1.dns_name}" }] cpu = 256 memory = 512 portMappings = [ { containerPort = 80 hostPort = 8080 } ] } ])

depends_on = []

}

resource "aws_security_group" "sg2-j1" { name = "sg2-j1" description = "j1 security group 2" vpc_id = module.vpc.vpc_id

ingress { from_port = 80 to_port = 80 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"]

}

egress { from_port = 0 to_port = 0 protocol = "-1" cidr_blocks = ["0.0.0.0/0"] }

tags = { Name = "sg2-j1" Terraform = "true" Environment = "test" } }

module "secrets-manager-2" {

source = "lgallard/secrets-manager/aws" version = "0.11.0"

secrets = { secret-secgit = { description = "This is a key/value secret" secret_key_value = { username = var.gitlab_deploy_token_username password = var.gitlab_deploy_token_password } recovery_window_in_days = 7 } } }

brave_Vm4oW347Dj
lgallard commented 10 months ago

If it works on your local machine, then it's something in the way you are using the module in GitHub Actions. Check if you need to escape characters to make it works.