provider/aws: guard against missing digestSha 7956 (#7966)

This commit is contained in:
Raphael Randschau 2016-08-04 21:26:43 +02:00 committed by Paul Stack
parent 98d8440711
commit 582e3bd883
2 changed files with 5 additions and 1 deletions

View File

@ -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))

View File

@ -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"),