terraform-aws-ecs-container-definition
terraform-aws-ecs-container-definition copied to clipboard
fix: strengthen types, simplify logic
trafficstars
what
- enable & use optional attributes where AWS API marks fields optional
- remove redundant lookups
- strengthen types for
log_configuration,repository_credentials,system_controls,container_definition - reorder object var attributes to match AWS docs
- simplify log configuration sanitization/munging
- simplify secret & environment var sorting
- expose unencoded container definition output directly without requiring pointless
jsonencode/jsondecodecycle
why
optionalobviateslookup(..., null)calls for objectslookup(o, k)without adefaultis deprecated in favor ofo[k]or direct attr access (o.k)log_configuration,repository_credentials, andsystem_controlshad needlessly opaqueanytypes which hinder DX and make subtle bugs more likely (e.g. in the types oflog_configuration.optionsvalues)- since all attributes of
container_definitionare now typed there's no reason not to type it as well - following the AWS documentation's field order makes types easier to verify for completeness & correctness
- typing
log_configurationappropriately obviates explicittostring&nullhandling; resolves #151 - env/secret map sorting can be dramatically simplified since
for-expressions iterate over maps & objects by key in lexicographic order jsonencode-ing the final container definition only tojsondecodeforjson_map_objectis redundant