-
Notifications
You must be signed in to change notification settings - Fork 9.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Data Source: aws_lambda_invocation #4222
Conversation
6b1fc05
to
4d2952b
Compare
4d2952b
to
1e09e14
Compare
Test results
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @spirius! Thanks for submitting this! I left some initial comments below. Can you please take a look and let us know if you have any questions or do not have time to implement the feedback? 👍
aws/data_source_aws_lambda_invoke.go
Outdated
"github.com/hashicorp/terraform/helper/schema" | ||
) | ||
|
||
func dataSourceAwsLambdaInvoke() *schema.Resource { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please rename all the relevant functions to dataSourceAwsLambdaFunctionInvocation
? Thanks!
aws/data_source_aws_lambda_invoke.go
Outdated
Default: "$LATEST", | ||
}, | ||
|
||
"input": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably make this TypeString
, which will allow us to use ValidateFunc: validateJsonString,
and remove JSON marshal handling/errors from the data source.
aws/data_source_aws_lambda_invoke.go
Outdated
}, | ||
}, | ||
|
||
"result": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here -- we should convert this to TypeString
and remove the JSON unmarshal handling/errors from the data source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use TypeString
for result
, how the returned data will be used later in terraform code? As far as I know there is no jsondecode
or similar function available.
aws/data_source_aws_lambda_invoke.go
Outdated
|
||
res, err := conn.Invoke(&lambda.InvokeInput{ | ||
FunctionName: aws.String(functionName), | ||
InvocationType: aws.String(lambda.InvocationTypeRequestResponse), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, we can allow a new invocation_type
attribute for calling Lambda functions asynchronously with Event
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, I wanted to keep the first version simple, but I think we can pass some random s3 key to lambda during invocation and expect to get result stored there.
aws/provider.go
Outdated
@@ -211,6 +211,7 @@ func Provider() terraform.ResourceProvider { | |||
"aws_kms_ciphertext": dataSourceAwsKmsCiphertext(), | |||
"aws_kms_key": dataSourceAwsKmsKey(), | |||
"aws_kms_secret": dataSourceAwsKmsSecret(), | |||
"aws_lambda_invoke": dataSourceAwsLambdaInvoke(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please rename the data source aws_lambda_function_invocation
? Thanks!
@spirius Apparently, there are conflicts with the master branch that need to be solved before anyone from Hashicorp can take further action on this. Would you mind addressing them? @bflad Apart from these conflicts, what else needs to be done in order to get this approved/merged into master? I'm happy to contribute to it in any way possible. Cheers! |
@PauloMigAlmeida conflict fixed. @bflad I've updated code according to your comments. The only question I have is regarding |
For handling the response, what do you think about the below? 😄
This enables these use cases:
|
Hi @bflad, renamed Test results:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working through this @spirius! Looks great, I just needed to randomize the test resource naming so the testing could work in our parallelized acceptance testing environment.
make testacc TEST=./aws TESTARGS='-run=TestAccDataSourceAwsLambdaInvocation'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccDataSourceAwsLambdaInvocation -timeout 120m
=== RUN TestAccDataSourceAwsLambdaInvocation_basic
--- PASS: TestAccDataSourceAwsLambdaInvocation_basic (39.70s)
=== RUN TestAccDataSourceAwsLambdaInvocation_qualifier
--- PASS: TestAccDataSourceAwsLambdaInvocation_qualifier (38.59s)
=== RUN TestAccDataSourceAwsLambdaInvocation_complex
--- PASS: TestAccDataSourceAwsLambdaInvocation_complex (38.83s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 117.159s
This has been released in version 1.19.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Data source for using lambda function as data provider, similar to External Data Source.