aws-sam-cli | CLI tool to build , test , debug , and deploy Serverless | REST library
kandi X-RAY | aws-sam-cli Summary
kandi X-RAY | aws-sam-cli Summary
This Github Repository contains source code for SAM CLI. Here is the development team talking about this code:.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Handles the request handler
- Create a service response object
- Return a JSON representation of this request
- Constructs a v1 event
- Normalizes a SAM template
- Replace a property in a resource
- Extracts image metadata
- Get debug settings
- Parse the command line arguments
- Invoke a function
- Creates a warm container
- Resolve fn_sub
- Validate code signing config
- Handle OR operator
- Manage a stack
- Handle an AND condition
- Validate the request
- Sync the Lambda function
- Return the value of an IF condition
- Create a new project from the given context
- Sync a stack
- Command line interface for AWS Lambda
- Common command line options
- Handle find in a map
- Decorator for image repository validation validation
- Start the application builder
aws-sam-cli Key Features
aws-sam-cli Examples and Code Snippets
export REGION=us-east-1
aws s3 cp s3://${REGION}.managedblockchain/etc/managedblockchain-tls-chain.pem src/main/resources/managedblockchain-tls-chain.pem
sam build
export ADMINUSER='YOUR_CA_ADMIN_USER'
export ADMINPWD='YOUR_CA_ADMIN_PASSWORD'
expo
Community Discussions
Trending Discussions on aws-sam-cli
QUESTION
I am trying to get a Flask and Docker application to work but when I try and run it using my docker-compose up
command in my Visual Studio terminal, it gives me an ImportError called ImportError: cannot import name 'json' from itsdangerous
. I have tried to look for possible solutions to this problem but as of right now there are not many on here or anywhere else. The only two solutions I could find are to change the current installation of MarkupSafe and itsdangerous to a higher version: https://serverfault.com/questions/1094062/from-itsdangerous-import-json-as-json-importerror-cannot-import-name-json-fr and another one on GitHub that tells me to essentially change the MarkUpSafe and itsdangerous installation again https://github.com/aws/aws-sam-cli/issues/3661, I have also tried to make a virtual environment named veganetworkscriptenv
to install the packages but that has also failed as well. I am currently using Flask 2.0.0 and Docker 5.0.0 and the error occurs on line eight in vegamain.py.
Here is the full ImportError that I get when I try and run the program:
...ANSWER
Answered 2022-Feb-20 at 12:31I was facing the same issue while running docker containers with flask.
I downgraded Flask
to 1.1.4
and markupsafe
to 2.0.1
which solved my issue.
Check this for reference.
QUESTION
I have created a Lambda function using AWS SAM CLI which is deployed as a container image. Problem is the requirements are downloaded every time I make a small change in the code(app.py) and run sam build. The reason can be undestood from the Dockerfile below.
Dockerfile
...ANSWER
Answered 2022-Mar-27 at 16:53With the way docker caching works, everything after your COPY
statements is invalidated in cache (assuming changing). The way dependencies are often retained in cache is by only adding what is necessary to install dependencies, installing them, and then only adding your service code once dependencies are installed. In the example below, the pip install
will only run more than once if requirements.txt changes.
QUESTION
I am trying to make an application using python and gRPC as shown in this article - link
I am able to run the app successfully on my terminal but to run with a frontend I need to run it as a flask app, codebase. And I am doing all this in a virtual environment.
when I run my flask command FLASK_APP=marketplace.py flask run
This is the error I get
...ANSWER
Answered 2022-Feb-26 at 04:28If downgrading will solve the issue for you try the following code inside your virtual environment.
pip install MarkupSafe==2.0.1
QUESTION
I'm trying to set up CI/CD for an AWS Lambda using the SAM cli tool inside a Gitlab runner.
My Lambda function is a Go app shipped as a container image.
I followed this article to set it up properly: https://aws.amazon.com/blogs/apn/using-gitlab-ci-cd-pipeline-to-deploy-aws-sam-applications/
Unfortunately, the used .gitlab-ci.yml
seems to be only applicable to functions of PackageType
Zip
, i.e. by uploading the application code to an S3 bucket:
ANSWER
Answered 2021-Dec-30 at 18:15You can:
- use the
docker
image and install python in your job OR - use the
python
image and install docker in your job OR - build your own image containing all your dependencies (docker, python, awscli, etc) and use that as your job's
image:
.
Installing python in the docker image:
QUESTION
Currently I'm using a dind configuration in gitlab
This dind works for me to deploy a dockerized lambda function through SAM.
This is my before script
...ANSWER
Answered 2021-Dec-28 at 21:23Finally I solve it Probably I lacked context I'm doing a gitlab.yaml file to build, test and deploy my application in AWS thorugh SAM.
Since one of my lambda functions is a dockerized lambda function I nee sam to be able to access docker
as a command so it can run docker pull
and docker build
The other lambda functions that I have use python3.8 as runtime so the docker version I was using as a base image pointed to https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/
so everyt time something was installed with apk
the version was 3.15 which has python3.10.
A solution to this is use:
image: docker:19.03.15-alpine3.13
as a base image with the service dind like this:
QUESTION
I have been getting the following error in my CodeBuild execution:
ModuleNotFoundError: No module named 'cfn_tools'
Interesting note, the first time I ran this through CodeBuild with this module I had no issues. It only started happening after I made my next gitHub push that kicked off my pipeline that I saw this. The files that are related to this didn't change, and the modifications in that next push were to an unrelated section of the repo.
I have since tried to do:
pip install cfn-tools
&pip3 install cfn-tools
which mentioned that the module was already installed. These were added to the BuildSpec section. No success - still got the error- I've added a requirements.txt file with no success still got the error. I created this file using
pip freeze
also within the BuildSpec. The module shows up, but still get the error. - Originally used runtime version 3.7 of python and then tried with 3.9 which still didn't work.
python runtime 3.9 Any assistance would be appreciated.
UPDATE: To add more information I download a .tar.gz file from S3 that contains the python scripts I need for running in this build. I extract the .tar.gz then I run the script that is having the error. Here is the output for when I install cfn-tools and do a pip freeze You will see below that cfn-tools loads and is part of the output of pip freeze but yet when I run my script it give me the above error.
...ANSWER
Answered 2021-Dec-20 at 19:11The module I was trying to install wasn't the one that was being used.
The module that needed to be installed was cfn_flip
it has the cfn_tools
module that the code was trying to use. The CodeBuild didn't have it installed, so how it worked on the first run is still a mystery.
QUESTION
Just getting started with AWS SAM. Wanted to create a CRUD micro service using Lambda and DynamoDB My template.yaml:
...ANSWER
Answered 2021-Dec-09 at 07:14Please ensure your yaml file is properly indented. The Type:
should be indented below the name of the resource, e.g.
QUESTION
Today I updated to AWS SAM CLI
version 1.33.0. Then it started crashing making issues during the deployment. When I run the command sam deploy
or sam deploy --guided
, it throws the following error
ANSWER
Answered 2021-Oct-18 at 17:47We have identified the issue and a fix is on the way. The issue is a version of regex. We need to pin to a specific version (2021.9.30) as later ones are having issues on M1. A new version of the CLI will address this.
For now, the workarounds are
- For brew installs:
/opt/homebrew/Cellar/aws-sam-cli/1.33.0/libexec/bin/pip3 install regex==2021.9.30
- For PIP installs:
pip install regex==2021.9.30
QUESTION
I have a AWS Lambda function that I am attempting to step-through debug with VSCode. I am running into an issue where the behaviour of the debugger and VSCode does not make sense, claiming it cannot resolve non-existent files from paths that it should not be looking for these packages at.
The lambda function has been tested locally using the aws-sam-cli
's sam build
and sam local invoke
functionality. The lambda correctly takes a JSON event with -e
, and returns the expected response. This has been tested with the following setup for its SAM template:
ANSWER
Answered 2021-Oct-13 at 18:13Solved. It relates to debugpy. See more here:
QUESTION
I am trying to split my stack into nested stack because i hit the AWS Max stack resource limit. I am building a REST API. I want to use a one API Gateway for all the stacks. Below is my code.
template.yaml
...ANSWER
Answered 2021-Aug-30 at 11:56If you look into the documentation for the API Event for the serverless function, they write:
RestApiId Identifier of a RestApi resource, which must contain an operation with the given path and method. Typically, this is set to reference an AWS::Serverless::Api resource defined in this template.
If you don't define this property, AWS SAM creates a default AWS::Serverless::Api resource using a generated OpenApi document. That resource contains a union of all paths and methods defined by Api events in the same template that do not specify a RestApiId.
This cannot reference an AWS::Serverless::Api resource defined in another template.
template.yaml:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install aws-sam-cli
Install SAM CLI
Build & Deploy a "Hello World" Web App
Install AWS Toolkit to use SAM with your favorite IDEs
Tutorials and Workshops
Lambda Powertools Utilities for building Lambda functions in Python, Java, and TypeScript
Extract text from images and store in a database using Amazon S3 and Amazon Rekognition services.
Detect when records are added to a database using Amazon DynamoDB database and asynchronous stream processing.
Explore popular patterns
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page