Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 0.21 force to have "hostPort" in port_mappings #50

Closed
magnetik opened this issue Oct 30, 2019 · 2 comments
Closed

Version 0.21 force to have "hostPort" in port_mappings #50

magnetik opened this issue Oct 30, 2019 · 2 comments

Comments

@magnetik
Copy link

Hi,

I was using the following port_mapping:

  port_mappings = [
    {
      containerPort = 80,
      protocol = "tcp"
    }
  ]

As far as I know it's perfectly valid when using the awsvpc networking mode, but latest version 0.21 fails with error: element 0: attribute "hostPort" is required.

Something is wrong in the module, right?

Thanks.

@magnetik magnetik changed the title Version 0.21 force to have "hostPort" in port_mappins Version 0.21 force to have "hostPort" in port_mappings Oct 30, 2019
@aknysh
Copy link
Member

aknysh commented Oct 30, 2019

@magnetik
no, eveything is OK with the new version, TF 0.12 has stricter typing, and in the TF 0.12 version the variable is defined as https://github.com/cloudposse/terraform-aws-ecs-container-definition/blob/master/variables.tf#L23

If you don't need any of the fields, set them to null (which is supported by TF 0.12)

port_mappings = [
    {
      containerPort = 80,
      protocol = "tcp",
     hostPort = null
    }
  ]

Whatever is set to null TF considers as if it was not provided at all.
Let us know if it fixes the issue

@magnetik
Copy link
Author

Oh right, adding null works for me !

It would be cool if terraform assumed that non present items as their default value, but okay :)

Thanks for the fast answer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants