cloudposse / terraform-aws-code-deploy

Terraform module to provision AWS Code Deploy app and group.
https://cloudposse.com/accelerate
Apache License 2.0
14 stars 23 forks source link

Unable to create an ec2 code-deploy #6

Closed StephenTan-TW closed 3 years ago

StephenTan-TW commented 3 years ago

Found a bug? Maybe our Slack Community can help.

Slack Community

Describe the Bug

I am trying to use your module for the following EC2 deployment. I get an issue when I try to use the ec2_tag_filter variable. When I run the plan, I get:

│ Error: Invalid function argument
│
│   on .terraform/modules/code-deploy-stargate-frontend/main.tf line 179, in resource "aws_codedeploy_deployment_group" "default":
│  179:         key   = lookup(ec2_tag_set.value, "key", null)
│     ├────────────────
│     │ ec2_tag_set.value is list of object with 1 element
│
│ Invalid value for "inputMap" parameter: lookup() requires a map as the first argument.
╵
╷
│ Error: Invalid function argument
│
│   on .terraform/modules/code-deploy-stargate-frontend/main.tf line 180, in resource "aws_codedeploy_deployment_group" "default":
│  180:         type  = lookup(ec2_tag_set.value, "type", null)
│     ├────────────────
│     │ ec2_tag_set.value is list of object with 1 element
│
│ Invalid value for "inputMap" parameter: lookup() requires a map as the first argument.
╵
╷
│ Error: Invalid function argument
│
│   on .terraform/modules/code-deploy-stargate-frontend/main.tf line 181, in resource "aws_codedeploy_deployment_group" "default":
│  181:         value = lookup(ec2_tag_set.value, "value", null)
│     ├────────────────
│     │ ec2_tag_set.value is list of object with 1 element
│
│ Invalid value for "inputMap" parameter: lookup() requires a map as the first argument.
╵

Expected Behavior

I expect the Plan to run!

Steps to Reproduce

Code:

module "code-deploy-stargate-frontend" {
  source    = "cloudposse/code-deploy/aws"
  version   = "0.1.1"
  delimiter = "-"
  deployment_style = {
    deployment_option = "WITHOUT_TRAFFIC_CONTROL"
    deployment_type   = "IN_PLACE"
  }
  ec2_tag_filter = [
    {
      key   = "Service"
      type  = "KEY_AND_VALUE"
      value = "test"
    },
  ]
  enabled          = true
  label_value_case = "upper"
  name             = "test"
  minimum_healthy_hosts = {
    type  = "HOST_COUNT"
    value = "1"
  }
  compute_platform            = "Server"
  service_role_arn            = "code-deploy-test"
  create_default_service_role = true
}

Screenshots

If applicable, add screenshots or logs to help explain your problem.

Environment (please complete the following information):

Anything that will help us triage the bug will help. Here are some ideas:

Additional Context

Add any other context about the problem here.

StephenTan-TW commented 3 years ago

I have created a PR which fixes this issue here: https://github.com/cloudposse/terraform-aws-code-deploy/pull/7