Skip to content
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

Feature request: Data Source for Lambda function #2578

Closed
et304383 opened this issue Dec 7, 2017 · 8 comments
Closed

Feature request: Data Source for Lambda function #2578

et304383 opened this issue Dec 7, 2017 · 8 comments
Labels
new-data-source Introduces a new data source. service/lambda Issues and PRs that pertain to the lambda service.
Milestone

Comments

@et304383
Copy link

et304383 commented Dec 7, 2017

The use case is simple: we create Lambda functions via serverless and want to reference that Lambda function in a terraform file when creating a Cognito user pool for custom verification flow.

There appears to be no easy way to get the Lambda function ARN in our terraform file.

@apparentlymart apparentlymart added enhancement Requests to existing resources that expand the functionality or scope. new-data-source Introduces a new data source. labels Dec 19, 2017
@apparentlymart
Copy link
Contributor

Hi @et304383! Thanks for this feature request.

We are generally in favor of adding new data sources where it makes it possible to fetch additional attributes for an object that wouldn't otherwise naturally be available, as in this case.

The Terraform team at HashiCorp won't be able to work on this in the near future due to our focus being elsewhere, but we'd be happy to review a pull request if you or someone else has the time and motivation to implement it. Alternatively, if others would also like to see this implemented I'd encourage adding a 👍 upvote reaction to the original issue comment (not to this comment), which we use as one of the inputs to prioritize work for the Terraform team.

@et304383
Copy link
Author

et304383 commented Dec 19, 2017

@loivis I explicitly said the Lambda fucntion is created outside of Terraform via Serverless.

@radeksimko radeksimko added service/lambda Issues and PRs that pertain to the lambda service. and removed enhancement Requests to existing resources that expand the functionality or scope. labels Jan 28, 2018
@jammycakes-ukpds
Copy link

As a workaround in the meantime, the ARN of a Lambda function is deterministic:

arn:aws:lambda:<region>:<account_id>:function:<function_name>

You can therefore do something like this:

data "aws_caller_identity" "current" {}

data "aws_region" "current" {}

Then reference your lambda function as:

"arn:aws:lambda:${data.aws_caller_identity.current.account_id}:${data.aws_region.current.name}:function:my_function"

@neg3ntropy
Copy link

@jammycakes-ukpds kudos, but region goes before account. This is the correct syntax:

"arn:aws:lambda:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:function:my_function"

@t-pascal
Copy link

Has this been addressed in #2984 ?

@bflad bflad added this to the v1.16.0 milestone Apr 23, 2018
@bflad
Copy link
Contributor

bflad commented Apr 23, 2018

Thanks @t-pascal! You're right. We have introduced a new aws_lambda_function data source via #2984 and it will release with v1.16.0 of the AWS provider, likely in a few days. 🎉

@bflad bflad closed this as completed Apr 23, 2018
@bflad
Copy link
Contributor

bflad commented Apr 25, 2018

This has been released in version 1.16.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 6, 2020

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!

@ghost ghost locked and limited conversation to collaborators Apr 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-data-source Introduces a new data source. service/lambda Issues and PRs that pertain to the lambda service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants