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

Support AWS::Lambda::Alias type resolving #7833

Merged
merged 3 commits into from
Jan 25, 2025

Conversation

rangerthegood
Copy link
Contributor

Which issue(s) does this change fix?

#7832

Why is this change necessary?

Without this change it is not possible to use start-api when your SpecRestApi is wired up with a Lambda function Alias versus just a Lambda, which would work fine.

How does it address the issue?

The code change introduces a new type resolvers for AWS::Lambda:Alias, This resolver works by looking at the FunctionName property. Once it has access to the function name it uses the existing arn_resolver function to retrieve the result.

What side effects does this change have?

None, that I'm aware of, I've introduced an additional test case to demonstrate the feature, and the existing test cases all still pass.

Mandatory Checklist

PRs will only be reviewed after checklist is complete

  • Add input/output type hints to new functions/methods
  • Write design document if needed (Do I need to write a design document?)
  • Write/update unit tests
  • Write/update integration tests
  • Write/update functional tests if needed
  • make pr passes
  • make update-reproducible-reqs if dependencies were changed
  • Write documentation

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@rangerthegood rangerthegood requested a review from a team as a code owner January 12, 2025 15:39
@github-actions github-actions bot added pr/external stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. labels Jan 12, 2025
@roger-zhangg roger-zhangg removed the stage/needs-triage Automatically applied to new issues and PRs, indicating they haven't been looked at. label Jan 24, 2025
@roger-zhangg
Copy link
Member

Hi @rangerthegood Thanks for sending the PR! I was trying to reproduce the issue you mentioned in the issue to better understand and review the PR. However the project I got from cdk synth then sam build, sam local start-api gives me a error that: Error: Template does not have any APIs connected to Lambda functions. in both live version and the version with the current PR. To better review this issue, do you mind create and upload a basic project that could reproduce the issue for me to easy verify the change? Thank you

@rangerthegood
Copy link
Contributor Author

Steps to reproduce:

Setup patched sam install:

git clone [email protected]:rangerthegood/aws-sam-cli.git sam-testing
 cd sam-testing/
 python3 -m venv venv
 git checkout function_alias
 pip install -e .

Setup POC CDK repo:

 git clone [email protected]:rangerthegood/sam-local-startapi-poc.git
 cd sam-local-startapi-poc/
 npm i
 npx cdk synth
 /home/ranger/projects/sam-testing/venv/bin/sam build -t cdk.out/Spec.template.json
 /home/ranger/projects/sam-testing/venv/bin/sam local start-api

Output:

No current session found, using default AWS::AccountId                                                                  Mounting HelloWorldFunctionSpec17441592 at http://127.0.0.1:3000/test [GET]                                             You can now browse to the above endpoints to invoke your functions. You do not need to restart/reload SAM CLI while     working on your functions, changes will be reflected instantly/automatically. If you used sam build before running localcommands, you will need to re-run sam build for the changes to be picked up. You only need to restart SAM CLI if you    update your AWS SAM template                                                                                            2025-01-24 20:50:51 WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:3000
2025-01-24 20:50:51 Press CTRL+C to quit

Copy link
Member

@roger-zhangg roger-zhangg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the sample project. LGTM!

@roger-zhangg roger-zhangg added this pull request to the merge queue Jan 25, 2025
Merged via the queue into aws:develop with commit 65d47c9 Jan 25, 2025
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants