Skip to content

Commit

Permalink
Merge pull request #21015 from razielgn/f-data-source-aws_lambda_func…
Browse files Browse the repository at this point in the history
…tion-add-image_uri

add `image_uri` to data source `aws_lambda_function`
  • Loading branch information
anGie44 committed Nov 25, 2021
2 parents d398b6b + 5d7f8b6 commit a6ac55b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/21015.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
data source/aws_lambda_function: Add `image_uri` attribute
```
8 changes: 8 additions & 0 deletions internal/service/lambda/function_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ func DataSourceFunction() *schema.Resource {
Type: schema.TypeString,
},
},
"image_uri": {
Type: schema.TypeString,
Computed: true,
},
},
}
}
Expand Down Expand Up @@ -258,6 +262,10 @@ func dataSourceFunctionRead(d *schema.ResourceData, meta interface{}) error {
d.Set("kms_key_arn", function.KMSKeyArn)
d.Set("last_modified", function.LastModified)

if output.Code != nil {
d.Set("image_uri", output.Code.ImageUri)
}

if err := d.Set("layers", flattenLayers(function.Layers)); err != nil {
return fmt.Errorf("Error setting layers for Lambda Function (%s): %w", d.Id(), err)
}
Expand Down
1 change: 1 addition & 0 deletions internal/service/lambda/function_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ func TestAccLambdaFunctionDataSource_image(t *testing.T) {
Config: testAccFunctionImageDataSourceConfig(rName, imageLatestID),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttrPair(dataSourceName, "code_signing_config_arn", resourceName, "code_signing_config_arn"),
resource.TestCheckResourceAttrPair(dataSourceName, "image_uri", resourceName, "image_uri"),
),
},
},
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/lambda_function.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ In addition to all arguments above, the following attributes are exported:
* `environment` - The Lambda environment's configuration settings.
* `file_system_config` - The connection settings for an Amazon EFS file system.
* `handler` - The function entrypoint in your code.
* `image_uri` - The URI of the container image.
* `invoke_arn` - The ARN to be used for invoking Lambda Function from API Gateway.
* `kms_key_arn` - The ARN for the KMS encryption key.
* `last_modified` - The date this resource was last modified.
Expand Down

0 comments on commit a6ac55b

Please sign in to comment.