Integrating with SAM
In order to use SAM in a CloudFormation Stack you'll need to do two things: create a Docker image with SAM included and invoke SAM in before_init hooks.
The first one can be done using a Dockerfile akin to this one:
1
FROM public.ecr.aws/spacelift/runner-terraform
2
USER root
3
WORKDIR /home/spacelift
4
RUN apk add --update --no-cache curl py-pip
5
RUN apk -v --no-cache --update add \
6
musl-dev \
7
gcc \
8
python3 \
9
python3-dev
10
RUN python3 -m ensurepip --upgrade \
11
&& pip3 install --upgrade pip
12
RUN pip3 install --upgrade awscli aws-sam-cli
13
RUN pip3 uninstall --yes pip \
14
&& apk del python3-dev gcc musl-dev
15
RUN sam --version
16
USER spacelift
Copied!
You should build it, push it to a repository and set it as the Runner Image of your Stack.
You'll also have to invoke SAM in order to generate raw CloudFormation files and upload Lambda artifacts to S3. You can do this by adding the following to your before initialization hooks:
sam package --region ${CF_METADATA_REGION} --s3-bucket ${CF_METADATA_TEMPLATE_BUCKET} --s3-prefix sam-artifacts --output-template-file ${CF_METADATA_ENTRY_TEMPLATE_FILE}
Copy link