quiet-lock-69596
03/28/2021, 2:56 PMerror: aws:ecs/taskDefinition:TaskDefinition resource 'api-task' has a problem: ECS Task Definition container_definitions is invalid: Error decoding JSON: json: cannot unmarshal number into Go struct field KeyValuePair.Environment.Value of type string. Examine values at 'TaskDefinition.ContainerDefinitions'.
So to my understanding is that my type conversion is wrong in some way. Can anybody maybe point me in the right direction or to some example covering how to add the variables.
Snippet of my code:
tmpContainerDef, err := json.Marshal([]map[string]interface{}{
{
"name": pulumi.Sprintf("%q", image.ImageName),
"image": pulumi.Sprintf("%q", image),
"cpu": 256,
"memory": 512,
"portMappings": []map[string]interface{}{
{
"containerPort": 8888,
},
},
"environment": []map[string]interface{}{
{
"name": "APP_ENV",
"value": "prod",
},
{
"name": "API_PORT",
"value": 8888,
},
{
"name": "DB_DRIVER",
"value": "postgres",
},
{
"name": "DB_HOST",
"value": pulumi.Sprintf("%q", dbCluster.Endpoint),
},
{
"name": "DB_NAME",
"value": pulumi.Sprintf("%q", dbCluster.DatabaseName),
},
{
"name": "DB_USER",
"value": pulumi.Sprintf("%q", dbCluster.MasterUsername),
},
{
"name": "DB_PORT",
"value": pulumi.Sprintf("%d", dbCluster.Port),
},
},
"secret": []map[string]interface{}{
{
"name": "API_SECRET",
"valueFrom": pulumi.Sprintf("%q", apiSecret.Arn),
},
{
"name": "DB_PASSWORD",
"valueFrom": pulumi.Sprintf("%q", dbSecret.Arn),
},
},
},
})
if err != nil {
return err
}
billowy-army-68599
03/28/2021, 6:55 PMdbSecret.Arn
is an eventual value, so you'll need to access it via an ApplyT
Here's an example:
https://github.com/jaxxstorm/iac-in-go/blob/fb5eb2c35ed9b4498b35701f3a3e4a43d6c896f7/bastion/main.go#L67-L93quiet-lock-69596
03/28/2021, 7:44 PMApplyT
with several values? Since I need more than just dbSecret.Arn
as eventual values.billowy-army-68599
03/28/2021, 8:36 PM.All
https://www.pulumi.com/docs/intro/concepts/inputs-outputs/#allquiet-lock-69596
03/29/2021, 5:50 AM