All Questions
Tagged with aws-cloudformation aws-sam
264
questions
85
votes
7
answers
37k
views
AWS SAM YAML template - Unknown Tag !Ref
When I try to deploy my AWS SAM YAML file, it fails saying the !Ref is an unknown tag.
Any ideas to get around this?
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
38
votes
6
answers
27k
views
Nested Step Function in a Step Function: Unknown Error: "...not authorized to create managed-rule"
I have a Step Function (Parent) created in a SAM/CloudFormation template that, among other things, calls another Step Function (Child). I'm following the instructions on calling Child, from Parent, ...
20
votes
1
answer
7k
views
Using Amplify and SAM together?
I'm having some confusion here and wanted to see if someone can set me straight.
I'm using Amplify for a Vue app. It calls API Gateway which calls Lambda and all of this is set up manually but I want ...
19
votes
10
answers
36k
views
Unable to upload artifact None referenced by CodeUri parameter of HelloWorldFunction resource
I'm following this tutorial to learn how to use SAM.
Here's the code I have:
template.yml:
AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Resources:
...
18
votes
5
answers
15k
views
Referencing !Ref DynamoDB table name in a AWS CloudFormation template
I am trying to locally test passing the table name of a DynamoDB table as declared in my CloudFormation template file.
From all the documentation I have read, I should be able to reference the the ...
14
votes
3
answers
6k
views
How to transform a Serverless Application Model (SAM) template to Cloudformation?
From this answer I understand that SAM is a transform of Cloudformation.
Is there a way to get the transformed Cloudformation template from a SAM template via the console, CLI, or another way?
13
votes
1
answer
1k
views
AWS SAM : Nested Stacks, Referring to API gateway from the Root stack
I want to split my SAM application into multiple parts.
I want to create a API ( AWS::Serverless::Api ) in the root stack.
I am creating lambda functions in my child stacks, where I want to give the ...
12
votes
4
answers
11k
views
Function not found after manually deleting a function in a SAM CloudFormation stack
I am using sam deploy to deploy lambda function and API gateway. It works fine but it doesn't work after I manually deleted the lambda function via AWS console. I got below error:
"...
10
votes
1
answer
7k
views
Multiple Lambda functions from the sam.yml file
Still waiting for actual AWS support for this:
https://github.com/aws-samples/aws-serverless-samfarm/issues/5
How is this supposed to work?
My use case is I have an API Gateway fronted lambda that ...
8
votes
2
answers
7k
views
sam package vs aws cloudformation package
The docs say they do exactly the same thing:
Both the sam package and sam deploy commands described in this section
are identical to their AWS CLI equivalent commands aws cloudformation
package ...
8
votes
2
answers
6k
views
AWS::ApiGateway::Stage requires DeploymentId ... but where do I find this?
I am trying to programmatically set up stages as part of my AWS API Gateway deployment. I am using SAM CLI. The cloudformation docs give the definition:
DeploymentId The ID of the deployment that ...
7
votes
3
answers
6k
views
How to create S3 and triggered lambda in 2 different cloudformation templates
Can a S3 bucket and triggered Lambda be created in separate CloudFormation templates. I want to keep long running resources stack separate from the likes of Lambda which get updated quite frequently
...
6
votes
3
answers
2k
views
SAM Template - define HttpApi with Lambda Authorizer and Simple Response
Description of the problem
I have created a Lambda function with API Gateway in SAM, then deployed it and it was working as expected. In API Gateway I used HttpApi not REST API.
Then, I wanted to add ...
6
votes
4
answers
4k
views
SAM API Gateway with Cloudformation WAFRegional
To secure our API, I'm trying to deploy a WAFRegional with a RateBasedRule. The API Gateway is located in a SAM template wherein I have also a nested stack for the child template holding the ...
6
votes
2
answers
3k
views
Manage stage and prod environments in AWS SAM/Cloudformation template along with CI/CD support
I'm having an AWS SAM template file with some resources hosted on github, a codepipeline has been setted up to detect changes in the repo then create/update and execute changes on cloudformation stack....
6
votes
3
answers
3k
views
AWS SAM Template - Define SQS queue triggered by API Gateway
I'm facing a problem when trying to deploy my stack via AWS SAM CLI. I'm using the SAM simplified template which I package and deploy.
All I want is to create an SQS queue and implicitly create an ...
6
votes
2
answers
4k
views
How can I write nested IF in serverless.yml using yaml format file while using it for cloud formation?
I'm trying to access secrets created in secrets manager(https://aws.amazon.com/secrets-manager/) via SSM (Systems Manager- https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-...
6
votes
0
answers
957
views
AWS API Gateway changes OAS3 path and query parameter types to string
When creating an API Gateway using an OAS3 definition, the path and query parameter types get changed to strings. I can't find any AWS documentation stating the expected behavior or why this is. I ...
5
votes
1
answer
4k
views
AWS S3 creation error: "The event is not supported for notifications (Service: Amazon S3; Status Code: 400; Error Code: InvalidArgument"
I'm developing my first lambda in Code9 that suppose to be triggered by S3 event. Unfortunetly, when I'm trying to deploy, I'm constantly getting CloudFormation Error:
"The event is not ...
5
votes
1
answer
8k
views
how to put the lambda in VPC by CloudFormation template
I am developping lambda with CloudFormation by SAM
My template.yaml is here.
It can be deployed, however this lambda is not set in VPC.
I want to put the lambda in default VPC (to access RDS)
Any ...
5
votes
4
answers
8k
views
How do you deploy cloudformation with a lambda function without inline code?
the lambda function size is over 4096 characters, so I can't deploy lambda function as inline codes in cloudformation template.
(https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-...
5
votes
1
answer
11k
views
AWS SAM: The REST API doesn't contain any methods
I'm trying to use AWS SAM to deploy a simple API.
When the API is simple (that is, does not specify explicitly an API Gateway). the deployment succeeds.
However, the following deployment fails:
...
5
votes
1
answer
3k
views
How to set up Custom Domain names with Route53 in AWS SAM Cloud-Formation
ORIGINAL QUESTIONS: How to get RegionalDomainName out of a AWS APIGateway DomainName in SAM Cloud-formation
EDIT: I changed the question to hopefully get more traffic to this answer as it answers ...
5
votes
1
answer
5k
views
How to write Resource-based policy in Cloudformation
I want to invoke a Lambda from an external AWS account, and I managed to do it by creating a Policy statement in the Resource-based policy tab of the console (Lambda > Configuration > ...
5
votes
1
answer
1k
views
Adding lambda integration to HttpApi routes with SAM
I am currently attempting to have a AWS::Serverless::HttpApi integrate with a group of AWS::Serverless::Function's. The goal is to define these resources within a SAM template, and define the actual ...
5
votes
1
answer
2k
views
In CloudFormation, how do I target a Lambda alias in Events::Rule
I'm trying to trigger a Lambda:alias (the alias is key here) on a schedule. The following code errors out with
"SampleLambdaLiveAlias is not valid. Reason: Provided Arn is not in
correct format. ...
5
votes
0
answers
1k
views
How to use SAM deploy to get a lambda, with AutoPublishAlias AND additional alises
My goal here is that additional SAM deploy calls will result in the :staging alias reflecting the latest version and :live will get updated by outside means, but has to be initialized to the same ...
5
votes
1
answer
557
views
Is it possible to configure different API Gateway stages with different lambda versions using AWS SAM
I have a SAM template for my application. Each time I deploy my SAM template with a new API Gateway stage name, it replaces the previously created stage.
So, found this article which helps me in ...
5
votes
2
answers
3k
views
AWS API Gateway api key required not set to 'true' after deployment
I have a .NET solution that uses a SAM template to generate cloudformation to deploy the stack. I am expecting the deployment - once complete - to have API Key Required = true on at least one of the ...
4
votes
1
answer
3k
views
API Name is always the Stack Name in SAM
I am using the AWS CLI to deploy a SAM template.
The AWS Api Name is being set to the same as the CloudFormation Stack Name. I expected the Api to be called "Users" based on this template content ...
4
votes
2
answers
3k
views
Building AWS Lambda layers with custom python functions using SAM
I am trying to build my lambda function using SAM. My lambda function depends on a custom python function which I plan to build as an AWS Lambda layer. My custom python function has a transitive ...
4
votes
2
answers
3k
views
How do you get the API endpoint's URL when it's created within the Events property of Cloudformation's Lambda definition
I'm creating a Lambda function via CloudFormation (AWS' SAM: Serverless Application Model) and have defined an API endpoint via the Lambda-function's Events property.
...
MyFunction:
Type: ...
4
votes
1
answer
170
views
How do I create a rule with CloudFormation that calls a Gateway API every few minutes?
I'm trying to create a CloudWatch rule in CloudFormation that triggers one of our Gateway APIs every few minutes and I'm having trouble finding documentation on how to fill certain parts of the ...
4
votes
1
answer
3k
views
SAM API Gateway caching with a method with query parameters
With the following SAM template:
Resources:
MyApi:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
CacheClusterEnabled: true
CacheClusterSize: '0.5'
...
4
votes
2
answers
4k
views
Does SAM Lambda auto-versioning using AutoPublishAlias work when code URL changes but the code that it points to doesn't?
Simple question:
Does SAM Lambda auto-versioning using AutoPublishAlias work for AWS::Serverless::Function when code CodeUri changes but the actual code that it points to doesn't?
Background
We are ...
4
votes
2
answers
2k
views
Dynamic AWS Sam Schedule Event Input param
We are automating a lambda via SAM to run on a Schedule Event. We use YAML but we are unable to work out how to use !Sub to make the Input be dynamic.
If you read the sam documentation it says that ...
4
votes
1
answer
439
views
Best practice to implement the actual blue/green deployment for serverless application created by cloudformation
[background]
Hi, I'm preparing to implement serverless application using cloudformation(aws-sam) and would like to apply blue/green deployment for production environment.
This application is actually ...
4
votes
0
answers
585
views
SAM give access to Cognito
I want to be able to call cognito functions through boto3 from my Lambda function in Python environment. What's the best way to give this type of access? I've done the following yaml but not sure if ...
3
votes
1
answer
6k
views
How to define CRUD policy in SAM (Serverless application model) template to more than one table for a lambda functio?
I am using SAM (Serverless application model) and creating policy for lambda function for dynamo. By default AmazonDynamoDBFullAccess is there but I want to give DynamoDBCrudPolicy for lambda function ...
3
votes
2
answers
2k
views
How do I get the name of a dynamically created lambda role?
I like how a role + inline policy is created when I deploy my template:
Resources:
MyFUnction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/...
3
votes
1
answer
6k
views
How do I reference a role defined in a SAM template?
I'm new to AWS SAM templates and want to be able to create a role with a selection of policies and then reference that role for a Lambda function. However, I get the following error when I try to ...
3
votes
1
answer
1k
views
Can I use the AWS Cloud Formation resource syntax into SAM template or vice-versa?
Recently, I have started learning AWS Cloud Formation (CF) and AWS Serverless Application Model (SAM). I found that there differences when it comes to syntax in its template files. For instance, to ...
3
votes
2
answers
4k
views
AWS SAM YAML File not able to refer to an existing bucket for S3 event
Use Case : Refer to an existing bucket while creating a S3 event for the Lambda function in SAM YAML file
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: ...
3
votes
1
answer
3k
views
Can SAM create the s3 bucket to store the lambda function code?
Perhaps this is more than one question. Tried to sign up to the SAM Slack channel, but no success.
I am trying out SAM to build a serverless app. I am used to having a Cloudformation template to ...
3
votes
1
answer
880
views
APIGateway returns `Internal server error` despite adding resource based permissions for Lambda
I built a simple HelloWorld API using a lambda function and APIGateway.
I'm using Cloudformation.
The lambda function runs fine when I run it using aws lambda invoke.
The API runs locally using sam ...
3
votes
1
answer
4k
views
Trigger lambda when object with specific prefix is created
I am creating a lambda that should be called when objects are created in a certain bucket. I only want it to be called for certain key prefixes. I have seen examples of setting this up using a ...
3
votes
2
answers
1k
views
AWS Lambda Application with Java resource
I have a project that I'm able to run locally, but it fails on AWS. To run the project locally I do sam build and then sam local start-api --host 0.0.0.0. Then I call http://localhost:3000/skill2/...
3
votes
1
answer
2k
views
How should I inject env vars with sam build
I am using AWS SAM.
I have created a samconfig.toml file with the following entry:
[default.build.parameters]
container_env_var_file = "envDefault.json"
When I do sam build I see in .aws-...
3
votes
1
answer
903
views
How can I let a null values pass in a sam template if it is in an API Gateway DefinitionBody as a response example
I have an OpenAPI 3.0.1 file and conforming to the standard it contains some examples responses for endpoints. Now since some of the parameters in the response are set to be nullable there are some ...