copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

exposing extra UDP port -- docs example not working

Open huanjani opened this issue 3 years ago • 0 comments

from https://gitter.im/aws/copilot-cli?at=63005387443b7927a798ec9f

Hey there, I'd like to expose two ports from the same container in a Backend Service.

I've referred to the following example: https://aws.github.io/copilot-cli/docs/developing/taskdef-overrides/#expose-an-extra-udp-port

And thus specified the following task definition override:

taskdef_overrides:
  - path: "ContainerDefinitions[0].PortMappings[-].ContainerPort"
    value: 43782

But receive the following error message:

Resource handler returned message: "Model validation failed (#/ContainerDefinitions/0/PortMappings: expected type: JSONArray, found: JSONObject)" (RequestToken: 5c10b1dc-964c-d69f-5493-8e55fb3faaa0, HandlerErrorCode: InvalidRequest)

I've also observed that this doesn't appear quite how I'd expect in the CloudFormation output:

PortMappings: !If [ExposePort, [{ContainerPort: !Ref ContainerPort}], !Ref "AWS::NoValue", {ContainerPort: 43782}]

If I adapt the example to:

taskdef_overrides:
  - path: "ContainerDefinitions[0].PortMappings"
    value:
      - ContainerPort: !Ref ContainerPort
      - ContainerPort: 43782

The resultant CloudFormation output looks better, but the validation error still persists.

Is this something that anyone has managed to do successfully? Has an unintentionally breaking change potentially been introduced since task definition overrides were introduced? Going to attempt a deployment with v1.10 of the CLI now.

update 1: On v1.10.1, I get the following error message:

ValidationError: Template error: Fn::If requires a list argument with three elements w/ the following override:

taskdef_overrides:
  - path: "ContainerDefinitions[0].PortMappings[-].ContainerPort"
    value: 43782

However, I am able to deploy successfully w/ the following override:

taskdef_overrides:
  - path: "ContainerDefinitions[0].PortMappings"
    value:
      - ContainerPort: !Ref ContainerPort
      - ContainerPort: 43782

update 2: Managed to get past the error on v1.21.0, by deleting the service and redeploying w/ the following override:

taskdef_overrides:
  - path: "ContainerDefinitions[0].PortMappings"
    value:
      - ContainerPort: !Ref ContainerPort
      - ContainerPort: 43782

huanjani avatar Aug 29 '22 18:08 huanjani