nice-scientist-89715
07/06/2021, 4:19 PM* ClientException: Environment variable name cannot be null or blank.
Seems to stem from the ContainerDefinitions
https://gist.github.com/urothis/197e866016a47d7f9db8e03596d2ef5b
Probably related to doing
{"environment", new[] { new Dictionary<string, object> {
{"PG_ENDPOINT", "potato"},
{"PG_READ_ENDPOINT", "banana"},
{"ASPNETCORE_URLS", "test"}
}}
},
Improperly.bored-oyster-3147
07/06/2021, 4:21 PMenvironment
key is expecting an array of dictionaries instead of just a dictionary?nice-scientist-89715
07/06/2021, 4:22 PMaws:ecs:TaskDefinition (api-runner-us-development):
error: aws:ecs/taskDefinition:TaskDefinition resource 'api-runner-us-development' has a problem: ECS Task Definition container_definitions is invalid: Error decoding JSON: json: cannot unmarshal object into Go struct field ContainerDefinition.Environment of type []*ecs.KeyValuePair. Examine values at 'TaskDefinition.ContainerDefinitions'.
When I try to remove the new[]bored-oyster-3147
07/06/2021, 4:25 PMenvironment
key and not an array. I would examine the JSON that is being returned from JsonSerializer.Serialize
when you omit the new []
and verify that it is valid.json
file and load it (doing any necessary variable placement) when I need the JSON. Your gist is just a bunch of static fields without any variable replacement into your container definition so there really isn't any reason to have the added complexity of creating strongly typed objects to represent it and then serialize when you could just load an already-valid JSON filenice-scientist-89715
07/06/2021, 4:31 PM[{"name":"first","image":"***.<http://dkr.ecr.us-west-2.amazonaws.com/***:***%22,%22environment%22:[{%22PG_ENDPOINT%22:%22potato%22,%22PG_READ_ENDPOINT%22:%22banana%22,%22ASPNETCORE_URLS%22:%22test%22}],%22cpu%22:10,%22memory%22:512,%22essential%22:true,%22portMappings%22:[{%22containerPort%22:5000,%22hostPort%22:80}]|dkr.ecr.us-west-2.amazonaws.com/***:***","environment":[{"PG_ENDPOINT":"potato","PG_READ_ENDPOINT":"banana","ASPNETCORE_URLS":"test"}],"cpu":10,"memory":512,"essential":true,"portMappings":[{"containerPort":5000,"hostPort":80}]>}]
bored-oyster-3147
07/06/2021, 4:36 PM"environment": [{"name": "variable-name", "value": "variable-value" }]
name, value
so it is not expecting a dictionarynice-scientist-89715
07/06/2021, 4:38 PMbored-oyster-3147
07/06/2021, 4:38 PMnice-scientist-89715
07/06/2021, 4:46 PM"environment":[{"Key":"PG_ENDPOINT","Value":"potato"},{"Key":"PG_READ_ENDPOINT","Value":"banana"},{"Key":"ASPNETCORE_URLS","Value":"test"}]
closerbored-oyster-3147
07/06/2021, 4:49 PMname
? weirdnice-scientist-89715
07/06/2021, 4:50 PMbored-oyster-3147
07/06/2021, 4:53 PMnice-scientist-89715
07/06/2021, 5:00 PMnamespace IAC.Helpers {
public class DockerVarHelper {
public string name { get; }
public string value { get; }
public DockerVarHelper(string Name, string Value) {
name = Name;
value = Value;
}
}
}