Questions tagged [aws-sam]

AWS Serverless Application Model (AWS-SAM) is an open source framework used to define, test and deploy serverless applications to the AWS Cloud.

From the Developer Guide:

Benefits of Using AWS SAM

Because AWS SAM integrates with other AWS services, creating serverless applications with AWS SAM provides the following benefits:

Single-deployment configuration

. AWS SAM makes it easy to organize related components and resources, and operate on a single stack. You can use AWS SAM to share configuration (such as memory and timeouts) between resources, and deploy all related resources together as a single, versioned entity.

Extension of AWS CloudFormation.

Because AWS SAM is an extension of AWS CloudFormation, you get the reliable deployment capabilities of AWS CloudFormation. You can define resources by using AWS CloudFormation in your AWS SAM template. Also, you can use the full suite of resources, intrinsic functions, and other template features that are available in AWS CloudFormation.

Built-in best practices.

You can use AWS SAM to define and deploy your infrastructure as config. This makes it possible for you to use and enforce best practices such as code reviews. Also, with a few lines of configuration, you can enable safe deployments through CodeDeploy, and can enable tracing by using AWS X-Ray.

Local debugging and testing.

The AWS SAM CLI lets you locally build, test, and debug serverless applications that are defined by AWS SAM templates. The CLI provides a Lambda-like execution environment locally. It helps you catch issues upfront by providing parity with the actual Lambda execution environment. To step through and debug your code to understand what the code is doing, you can use AWS SAM with AWS toolkits like the AWS Toolkit for JetBrains, AWS Toolkit for PyCharm, AWS Toolkit for IntelliJ, and AWS Toolkit for Visual Studio Code. This tightens the feedback loop by making it possible for you to find and troubleshoot issues that you might run into in the cloud.

Deep integration with development tools.

You can use AWS SAM with a suite of AWS tools for building serverless applications. You can discover new applications in the AWS Serverless Application Repository. For authoring, testing, and debugging AWS SAM–based serverless applications, you can use the AWS Cloud9 IDE. To build a deployment pipeline for your serverless applications, you can use CodeBuild, CodeDeploy, and CodePipeline. You can also use AWS CodeStar to get started with a project structure, code repository, and a CI/CD pipeline that's automatically configured for you. To deploy your serverless application, you can use the Jenkins plugin. You can use the Stackery.io toolkit to build production-ready applications.

1001 questions
8
votes
2 answers

AWS SAM Template setting environment specific variables

I am trying to configure a Lambda function's S3 policy bucket that is environment specific. I would like to be able to pass a variable during either "sam package" or "sam deploy" specifying "dev", "test" or "prod". The variable would be used in the…
tamsler
  • 1,275
  • 1
  • 18
  • 26
8
votes
1 answer

How to add a request validator in a AWS SAM template for AWS::Serverless::Api?

I'm trying to use AWS SAM to link a request validator resource to a serverless API in a SAM template. I have created the request validator and referenced the API in its RestApiId but the validator doesn't get set as the API default validator option…
8
votes
3 answers

How to trigger lambda with some delay when message published to SQS?

I have a lambda configured to be triggered when messages are published to SQS queue. Here is the SAM template for deployment. MyQueue: Type: AWS::SQS::Queue Properties: VisibilityTimeout: 180 DelaySeconds: 90 MyLambda: …
Affan Shahab
  • 838
  • 3
  • 17
  • 39
8
votes
1 answer

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 the stage points to. Required: Yes Type:…
HolyMoly
  • 2,020
  • 3
  • 22
  • 35
8
votes
2 answers

Create an API Key and Usage Plan with SAM

I am learning AWS SAM and having trouble finding information on how to create an API Key and usage plan through the SAM template. AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Resources: GetFamilyByIdFunction: …
badgerduke
  • 255
  • 4
  • 12
8
votes
1 answer

Using SAM application how to define body mapping templates

I am new to AWS and SAM. I am developing a dummy backend using AWS services. For that, I am using SAM application to write the code locally. I defined the structure of APIs and Lambda in that as AWSTemplateFormatVersion: '2010-09-09' Transform:…
Sai M.
  • 2,548
  • 4
  • 29
  • 46
7
votes
5 answers

AWS Serverless Application Model init error on Pycharm

I am trying to create a new AWS Serverless Application on Pycharm but i am getting this error: Could not execute `sam init`!: [Cloning from https://github.com/aws/aws-sam-cli-app-templates (process may take a moment), Error: Unstable state when…
Utku Can
  • 683
  • 3
  • 12
7
votes
1 answer

Allow developers to create AWS Lambda or SAM without granting Administrator access

It seems to be impossible to allow developers to create Lambdas and create or maintain SAM Applications in AWS without essentially having AdministratorAccess policies attached to their developer's role. AWS documents a suggested IAM setup where…
7
votes
3 answers

AWS SAM Multiple Functions with same Inline Policy

In the AWS SAM .yaml template I can declare an inline policy for each lambda function like so: AWSTemplateFormatVersion: '2010-09-09' Transform: 'AWS::Serverless-2016-10-31' Resources: MyFunction: Type: 'AWS::Serverless::Function' …
Niall Parker
  • 177
  • 7
7
votes
3 answers

An error occurred (UnrecognizedClientException) when calling the GetSecretValue operation: The security token included in the request is invalid

Please check below is the screenshot it is having problem. Aws credentials are configured correctly and its working fine when we use separately in boto3 but in SAM lambda function trigger it getting this error.enter image description here tried with…
Vijaya Teja M
  • 71
  • 1
  • 1
  • 2
7
votes
1 answer

How can I set Request Validator with AWS SAM?

I defined a model with JSONschema and set it to the lambda. I could see that the model was added in Request Body like the picture below But I also need to set Request Validator to validate it. This is my example AWS SAM template below. Resources: …
Jayground
  • 1,797
  • 1
  • 17
  • 32
7
votes
1 answer

AWS SAM Deployment : Error fork/exec /var/task/myfunction : no such file or directory: PathError

I have developed a set of Lambda functions in Golang and trying to deploy these functions and API gateway using SAM. I am creating the executables locally, creating zip file for each of these lambda functions and and uploading these zip files to s3…
Dattatray
  • 1,745
  • 1
  • 21
  • 49
7
votes
2 answers

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 and aws cloudformation deploy, respectively. But…
7
votes
3 answers

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 When tried to create Lambda separately it says…
7
votes
1 answer

How to provide global environment variables to AWS SAM local

When running sams locally to test my api gateway and passing environment variables, I can run the command sam local start-api -n env-vars.json This works well when the environment variables are tied to a specific function like this MyFunction: …
Gary Holiday
  • 3,297
  • 3
  • 31
  • 72
1 2
3
66 67