Open jaxxstorm opened 2 years ago
This appears to be related to portMappings
. I'm defining my own targetGroup
.
If I do the following:
const svc = new awsx.ecs.FargateService("cal", {
cluster: cluster.id,
tags: tags,
networkConfiguration: {
assignPublicIp: true,
subnets: publicSubnets,
securityGroups: [ appSg.id ]
},
taskDefinitionArgs: {
container: {
image: "nginx",
essential: true,
// portMappings: [{
// containerPort: 80,
// targetGroup: loadbalancer.targetGroup,
// }]
}
}
})
It works successfully.
Hi @jaxxstorm
I also stumbled on this error, when there is an error in the container config it just ignores the container.
Looking at your snippet using awsx
I would expect loadbalancer.defaultTargetGroup
instead of loadbalancer.targetGroup
cheers Wim
@jaxxstorm Is there any sort of update on this? I am experiencing the issue when I provide an aws.lb.TargetGroup
resource in the portMappings
block of an awsx.ecs.EC2Service
.
I am defining a custom TargetGroup, rather than grabbing defaultTargetGroup
off of an awsx alb.
In fact, I'm not using awsx for any of the LB resources (alb, target groups, listeners, listener rules, etc)
I'm doing the same thing successfully on an awsx.ecs.FargateService
, except I'm passing the custom TargetGroup via a StackReference.
Just confirmed that my EC2Service also works when the target group is provided via StackReference
I am seeing the same issue when passing a custom TargetGroup in the portMappings config for a awsx.ecs.FargateService.
I've been seeing this issue too, and if you add multiple containers you will get even more funny message, anyway I was able to solve it by:
loadbalancer.defaultTargetGroup.apply(targetGroup => {
new awsx.ecs.FargateService("cal", {
// ...
taskDefinitionArgs: {
container: {
// ...
portMappings: [{ targetGroup }]
}
}
});
})
Although, I've changed that to:
new awsx.ecs.FargateService("cal", {
// ...
taskDefinitionArgs: {
container: {
// ...
portMappings: [{ targetGroup: loadbalancer.defaultTargetGroup }]
}
}
}, {
dependsOn: [loadBalancer.defaultTargetGroup]
});
I use defaultTargetGroup
as I let awsx create it, you can use any aws.lb.TargetGroup
instance I believe.
I think the type definition of the targetGroup
property is (unnecessarily) specific. The only two attributes it really needs are the LB's arn
and port
. Until this becomes a bit more flexible, you can use ...
new awsx.ecs.FargateService("cal", {
// ...
taskDefinitionArgs: {
container: {
// ...
portMappings: [
{
targetGroup: { arn: loadbalancer.arn, port: loadbalancer.port } as any,
}
],
},
// ...
},
})
We had the same issue. Using a custom target group in portMappings
was followed by the this error:
UNKNOWN: Exactly one of [container] or [containers] must be provided
But we found a workaround! After wrapping the new TargetGroup
in a pulumi.Output.create
the problem was fixed. I am still not sure why:
const targetGroup = pulumi.Output.create(new aws.alb.TargetGroup(`custom-tg`, {
port: 80,
protocol: 'HTTP',
vpcId: evaluateVpcId,
targetType: 'ip',
}))
I'm currently running into this issue when using the Using AWS Elastic Container Service example. Seems like it still isn't fixed?
this is still a problem, though wrapping the targetGroup in an output is an effective workaround
This appears to be due to the underlying https://github.com/pulumi/pulumi/issues/13802 in the core platform. I believe it will need to be fixed there.
For me the problem was sharing the same package.json
between my app and pulumi. After adding the pulumi package.json
to the folder where my pulumi files are, the problem disappeared.
I believe I have run into a related issue. We are successfully able to use a custom targetGroup, but the object is mangled in the stack.
{
"containerDefinitions": [
{
"portMappings": [
{
"containerPort": 3000,
"protocol": "tcp",
"targetGroup": {
"__pulumiResource": true,
"__pulumiType": "aws:lb/targetGroup:TargetGroup",
"__transformations": [],
"__name": "tg-grafana-prod",
"__providers": {},
"__protect": false,
"__version": "6.9.0",
"__aliases": [
"Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi."
],
"urn": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"id": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"connectionTermination": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"deregistrationDelay": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"healthCheck": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"ipAddressType": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"lambdaMultiValueHeadersEnabled": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"loadBalancingAlgorithmType": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"loadBalancingCrossZoneEnabled": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"name": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"namePrefix": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"port": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"preserveClientIp": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"protocol": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"protocolVersion": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"proxyProtocolV2": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"slowStart": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"stickiness": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"tags": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"targetFailovers": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"targetHealthStates": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"targetType": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"vpcId": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"arn": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"arnSuffix": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"tagsAll": "Calling [toJSON] on an [Output<T>] is not supported.\\n\\nTo get the value of an Output as a JSON value or JSON string consider either:\\n 1: o.apply(v => v.toJSON())\\n 2: o.apply(v => JSON.stringify(v))\\n\\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\\nThis function may throw in a future version of @pulumi/pulumi.",
"__pulumiCustomResource": true
},
"hostPort": 3000
}
]
}
]
}
This seems to also be what happens when you wrap the targetGroup in a pulumi.Output.create()
. Although, this is not what we do. We pass the target group through a function argument as so:
interface CreateContainerArgs {
targetGroup: aws.lb.TargetGroup
}
function createService(args: CreateContainerArgs) {
new awsx.ecs.FargateService("test", {
// ...
taskDefinitionArgs: {
container: {
// ...
portMappings: [
{
targetGroup: args.targetGroup,
}
],
},
// ...
},
})
}
Both result in the same mangled stack shown above
What happened?
Steps to reproduce
Use the above code
Expected Behavior
I can define a fargate service
Actual Behavior
I cannot
Versions used
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).