provider/aws: guard against missing digestSha 7956 (#7966)
This commit is contained in:
parent
98d8440711
commit
582e3bd883
|
@ -77,7 +77,10 @@ func dataSourceAwsEcsContainerDefinitionRead(d *schema.ResourceData, meta interf
|
|||
|
||||
d.SetId(fmt.Sprintf("%s/%s", aws.StringValue(taskDefinition.TaskDefinitionArn), d.Get("container_name").(string)))
|
||||
d.Set("image", aws.StringValue(def.Image))
|
||||
d.Set("image_digest", strings.Split(aws.StringValue(def.Image), ":")[1])
|
||||
image := aws.StringValue(def.Image)
|
||||
if strings.Contains(image, ":") {
|
||||
d.Set("image_digest", strings.Split(image, ":")[1])
|
||||
}
|
||||
d.Set("cpu", aws.Int64Value(def.Cpu))
|
||||
d.Set("memory", aws.Int64Value(def.Memory))
|
||||
d.Set("disable_networking", aws.BoolValue(def.DisableNetworking))
|
||||
|
|
|
@ -15,6 +15,7 @@ func TestAccAWSEcsDataSource_ecsContainerDefinition(t *testing.T) {
|
|||
Config: testAccCheckAwsEcsContainerDefinitionDataSourceConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "image", "mongo:latest"),
|
||||
resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "image_digest", "latest"),
|
||||
resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "memory", "128"),
|
||||
resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "cpu", "128"),
|
||||
resource.TestCheckResourceAttr("data.aws_ecs_container_definition.mongo", "environment.SECRET", "KEY"),
|
||||
|
|
Loading…
Reference in New Issue