Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
data-source/aws_lambda_function: Implement standalone Read function a…
…nd refactor testing to check data source state values against the resource state values References: * #5812 * hashicorp/terraform#10810 (comment) * #6966 Previously, the `aws_lambda_function` data source was utilizing the Read function from the `aws_lambda_function` resource. This legacy practice has longterm maintenance issues with missing schema and documentation updates. Here we implement a fresh new Read function for the data source that includes the following changes: * Properly error when Lambda Function is not found * Always return the `arn` attribute as unqualified (e.g. without a qualifier or version suffix) * Always return the `qualified_arn` attribute as qualified (e.g. with the qualifier or version suffix) * Always return the `tags` attribute The acceptance testing changes modernize and simplify the testing: * Utilize `resource.TestCheckResourceAttrPair()` where possible to ensure data source state values match appropriate resource state values * Consolidate random naming to single variable * Only provision VPC resources in VPC specific test Output from acceptance testing: ``` --- PASS: TestAccDataSourceAWSLambdaFunction_version (20.89s) --- PASS: TestAccDataSourceAWSLambdaFunction_environment (22.75s) --- PASS: TestAccDataSourceAWSLambdaFunction_alias (23.68s) --- PASS: TestAccDataSourceAWSLambdaFunction_basic (23.76s) --- PASS: TestAccDataSourceAWSLambdaFunction_layers (28.82s) --- PASS: TestAccDataSourceAWSLambdaFunction_vpc (36.48s) ```
- Loading branch information