You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Updates the code and configuration of AWS Lambda functions as part of GitHub Actions workflow steps.
3
+
Updates the code and configuration of AWS Lambda functions as part of GitHub Actions workflow steps. Supports both .zip file archives and container images stored in Amazon ECR.
4
4
5
5
**Table of Contents**
6
6
@@ -10,6 +10,7 @@ Updates the code and configuration of AWS Lambda functions as part of GitHub Act
10
10
*[Update Function Configuration](#update-function-configuration)
# The role-to-assume should be the ARN of the IAM role you created for GitHub Actions OIDC
52
53
53
54
- name: Deploy Lambda Function
54
-
uses: aws-actions/aws-lambda-deploy@v1
55
+
uses: aws-actions/aws-lambda-deploy@v1.1.0
55
56
with:
56
57
function-name: my-function-name
57
58
code-artifacts-dir: my-code-artifacts-dir
@@ -60,9 +61,22 @@ jobs:
60
61
# Add any additional inputs this action supports
61
62
```
62
63
63
-
The required parameters to deploy are `function-name`, `code-artifacts-dir`, `handler`, and `runtime`. If the function does not exist yet, the `role` parameter is also required to specify the function's IAM execution role.
64
+
The required parameters depend on the deployment type:
64
65
65
-
If a function with the name specified by `function-name` does not exist, it will be created with the provided code within `code-artifacts-dir` and configuration parameters using the [CreateFunction](https://docs.aws.amazon.com/lambda/latest/api/API_CreateFunction.html) API.
66
+
**For zip file deployments (default):**
67
+
-`function-name` - Name of the Lambda function
68
+
-`code-artifacts-dir` - Path to code artifacts directory
69
+
-`handler` - Function handler method
70
+
-`runtime` - Function runtime identifier
71
+
72
+
**For container image deployments:**
73
+
-`function-name` - Name of the Lambda function
74
+
-`package-type` - Must be set to `Image`
75
+
-`image-uri` - URI of the container image in Amazon ECR
76
+
77
+
**Note:** If the function does not exist yet, the `role` parameter is also required for both deployment types to specify the function's IAM execution role.
78
+
79
+
If a function with the name specified by `function-name` does not exist, it will be created with the provided code or image and configuration parameters using the [CreateFunction](https://docs.aws.amazon.com/lambda/latest/api/API_CreateFunction.html) API.
66
80
67
81
For the full list of inputs this GitHub Action supports, see [Inputs](#inputs).
68
82
@@ -72,7 +86,7 @@ Function configuration will be updated using the [UpdateFunctionConfiguration](h
72
86
As a first step, [GetFunctionConfiguration](https://docs.aws.amazon.com/lambda/latest/api/API_GetFunctionConfiguration.html) is called to perform a diff between the provided configuration parameters and the configuration of the currently deployed function. If there is no change, UpdateFunctionConfiguration will not be called.
73
87
```yaml
74
88
- name: Update Lambda configuration
75
-
uses: aws-actions/aws-lambda-deploy@v1
89
+
uses: aws-actions/aws-lambda-deploy@v1.1.0
76
90
with:
77
91
function-name: my-function-name
78
92
code-artifacts-dir: my-code-artifacts-dir
@@ -82,10 +96,10 @@ As a first step, [GetFunctionConfiguration](https://docs.aws.amazon.com/lambda/l
82
96
```
83
97
84
98
### Using S3 Deployment Method
85
-
Optionally store code artifacts in S3 instead of direct `.zip` file upload.
99
+
For zip file deployments, you can optionally store code artifacts in S3 instead of direct `.zip` file upload. Note: This method is only available for zip deployments, not container images.
86
100
```yaml
87
101
- name: Deploy Lambda function via S3
88
-
uses: aws-actions/aws-lambda-deploy@v1
102
+
uses: aws-actions/aws-lambda-deploy@v1.1.0
89
103
with:
90
104
function-name: my-function-name
91
105
code-artifacts-dir: my-code-artifacts-dir
@@ -97,16 +111,48 @@ Optionally store code artifacts in S3 instead of direct `.zip` file upload.
97
111
Validate parameters and permissions without any function code or configuration modifications.
98
112
```yaml
99
113
- name: Deploy on dry run mode
100
-
uses: aws-actions/aws-lambda-deploy@v1
114
+
uses: aws-actions/aws-lambda-deploy@v1.1.0
101
115
with:
102
116
function-name: my-function-name
103
117
code-artifacts-dir: my-code-artifacts-dir
104
118
dry-run: true
105
119
```
106
-
**Note**: Dry run will still call `GetFunctionConfiguration` to check if the function exists and perform configuration diffs against what's currently deployed.
120
+
**Note**: Dry run will still call `GetFunctionConfiguration` to check if the function exists and perform configuration diffs against what's currently deployed.
121
+
122
+
### Container Image Deployment
123
+
Deploy Lambda functions using container images from Amazon ECR. See [aws-actions/amazon-ecr-login](https://github.com/aws-actions/amazon-ecr-login) for details on logging into ECR.
124
+
```yaml
125
+
- name: Login to Amazon ECR
126
+
id: login-ecr
127
+
uses: aws-actions/amazon-ecr-login@v1
128
+
# Authenticates with ECR and returns the registry URL for building images
image-uri: ${{ steps.build-image.outputs.image }} # ECR image URI from previous step
150
+
role: arn:aws:iam::123456789012:role/lambda-role # IAM execution role for Lambda
151
+
# Note: handler, runtime, and layers should not be provided for container images
152
+
```
107
153
## Build from Source
108
154
109
-
To automate building your source code, add a build step based on your runtime and build process. This build step should be performed before the AWS Lambda Deploy step, and AWS Lambda Deploy's `code-artifacts-dir` parameter will typically be set to the build step's code artifact output directory.
155
+
For zip file deployments, to automate building your source code, add a build step based on your runtime and build process. This build step should be performed before the AWS Lambda Deploy step, and AWS Lambda Deploy's `code-artifacts-dir` parameter will typically be set to the build step's code artifact output directory.
110
156
111
157
Below are two commonly used Build examples for Node.js and Python:
112
158
@@ -138,9 +184,11 @@ Below are two commonly used Build examples for Node.js and Python:
138
184
| Name | Description | Required | Default |
139
185
|------|-------------|----------|---------|
140
186
| `function-name` | Name of the Lambda function | Yes | |
141
-
| `code-artifacts-dir` | Path to a directory of code artifacts to zip and deploy | Yes | |
142
-
| `handler` | Name of the function handler method | Yes | `index.handler` |
**Note:** The above permissions include both push and pull operations for ECR. If you're only pulling pre-built images (not pushing), you can remove the write permissions and keep only:
336
+
- `ecr:BatchGetImage`
337
+
- `ecr:GetDownloadUrlForLayer`
338
+
339
+
**2. ECR repository policy** to allow the Lambda service to pull images:
340
+
341
+
```json
342
+
{
343
+
"Version": "2012-10-17",
344
+
"Statement": [
345
+
{
346
+
"Sid": "LambdaECRImageRetrievalPolicy",
347
+
"Effect": "Allow",
348
+
"Principal": {
349
+
"Service": "lambda.amazonaws.com"
350
+
},
351
+
"Action": [
352
+
"ecr:BatchGetImage",
353
+
"ecr:GetDownloadUrlForLayer"
354
+
]
355
+
}
356
+
]
357
+
}
358
+
```
359
+
360
+
For cross-account deployments or more details, see [AWS Lambda container image deployment documentation](https://docs.aws.amazon.com/lambda/latest/dg/images-create.html#images-create-permissions).
361
+
362
+
If you're using the S3 deployment method (for zip file deployments), ensure your IAM role also has the following permissions:
256
363
257
364
```json
258
365
{
@@ -264,6 +371,7 @@ If you're using the S3 deployment method, ensure your IAM role also has the foll
0 commit comments