Deploy to Amazon EC2, ECS, Elastic Beanstalk, CodeDeploy, and Lambda using CloudBees AWS deployment actions.
| Lambda actions require AWS credentials to be configured before use. Add the following step before invoking any Lambda action in your YAML file: |
- name: Configure AWS credentials uses: https://github.com/cloudbees-io/configure-aws-credentials@v1 with: aws-access-key-id: ${{ secrets.MY_KEY_ID }} aws-secret-access-key: ${{ secrets.MY_SECRET_KEY }} aws-region: eu-west-3
Refer to Configure AWS credentials.
Deploy a binary with Amazon EC2
Use the cloudbees-io/ec2-deploy-binary action to copy files to an Amazon EC2 host and optionally execute a command or script after deployment.
| All CloudBees action repositories are listed at CloudBees, Inc. on GitHub. |
Inputs
| Input name | Data type | Required? | Description |
|---|---|---|---|
|
String |
Yes |
The Amazon EC2 host URL. |
|
String |
Yes |
The AWS SSH key data. |
|
String |
Yes |
The AWS user to connect as. |
|
String |
Yes |
The source location to copy files from. |
|
String |
Yes |
The destination location in the Amazon EC2 host. |
|
String |
No |
The command to execute after deploying to the destination location. |
|
String |
No |
The script file to execute after deploying to the destination location. |
Usage example
In your YAML file, add:
- name: Deploy EC2 binary uses: https://github.com/cloudbees-io/ec2-deploy-binary@v1 with: source-location: workspace/test/* destination-ec2-location: /home/ubuntu/mydeploys/helloworld/ aws-ssh-key-data: ${{ secrets.AWS-DEPLOY-KEY }} aws-user: ubuntu aws-host: ${{ secrets.AWS-HOST }} deploy-script: script1.sh
Render an ECS task definition
Use the cloudbees-io/ecs-render-task-definition action to render an Amazon ECS task definition by injecting a container image and optional environment variables into an existing definition.
| All CloudBees action repositories are listed at CloudBees, Inc. on GitHub. |
Inputs
| Input name | Data type | Required? | Description |
|---|---|---|---|
|
String |
Required only if |
The ECS task definition name. |
|
String |
Required only if |
The path to the ECS task definition JSON file. |
|
String |
Yes |
The container name as defined in the ECS task definition (in |
|
String |
Yes |
The container image URL. |
|
JSON |
No |
Container variables, formatted as JSON data in key/value pairs. |
|
String |
No |
The path of the file that contains the environment variables. |
Usage example
In your YAML file, add:
- name: Render task definition uses: https://github.com/cloudbees-io/ecs-render-task-definition@v1 with: task-definition: test/taskDefinition.json container-name: container_name image: ${{ vars.IMAGE_URL }} environment-variables: '{"LOG_LEVEL"="info","ENVIRONMENT"="prod"}' environment-variables-path: sample/example.json
Deploy to Amazon ECS
Use the cloudbees-io/ecs-deploy-task-definition action to deploy to an Amazon ECS cluster using either a service name or a task definition.
| All CloudBees action repositories are listed at CloudBees, Inc. on GitHub. |
Inputs
| Input name | Data type | Required? | Description |
|---|---|---|---|
|
String |
Required only if |
The path to the ECS task definition JSON file. |
|
String |
Required only if |
The name of the ECS service to deploy to. |
|
String |
Yes |
The name of the ECS cluster to deploy to. |
|
Boolean |
Yes |
Whether to wait for the ECS service to reach a stable state after deploying the new task definition.
Default value is |
|
String |
Yes |
The amount of time to wait for the ECS service to reach a stable state, in minutes.
The default is |
|
Boolean |
Yes |
Whether to force a new service deployment.
Default value is |
Usage example
In your YAML file, add:
- name: Deploy task definition uses: https://github.com/cloudbees-io/ecs-deploy-task-definition@v1 with: task-definition: test/taskDefinition.json service: ECS_service_name cluster: ECS_cluster_name wait-for-service-stability: true wait-for-minutes: 6 hours force-new-deployment: true
Deploy with Elastic Beanstalk
Use the cloudbees-io/aws-elastic-beanstalk-invoke-deployment action to create a new application version from a source bundle and update an AWS Elastic Beanstalk environment.
| All CloudBees action repositories are listed at CloudBees, Inc. on GitHub. |
Inputs
| Input name | Data type | Required? | Description |
|---|---|---|---|
|
String |
Yes |
The Elastic Beanstalk application name. |
|
String |
Yes |
The S3 bucket name. |
|
String |
Yes |
The S3 key for the source bundle. |
|
String |
Yes |
The Elastic Beanstalk application version label to be created from the source bundle. |
|
String |
Yes |
The name of the Elastic Beanstalk environment to be updated. |
Usage example
In your YAML file, add:
- name: Update Elastic Beanstalk environment uses: https://github.com/cloudbees-io/aws-elastic-beanstalk-invoke-deployment@v1 with: application-name: your-elastic-beanstalk-application s3-bucket: your-s3-bucket s3-key: your-s3-key-for-the-source-bundle version-label: your-application-version-to-be-created environment-name: your-elastic-beanstalk-environment-to-be-updated
Deploy with CodeDeploy
Use the cloudbees-io/aws-codedeploy-invoke-deployment action to trigger an AWS CodeDeploy deployment and retrieve the run information as output.
| All CloudBees action repositories are listed at CloudBees, Inc. on GitHub. |
Inputs
| Input name | Data type | Required? | Description |
|---|---|---|---|
|
String |
Yes |
The AWS CodeDeploy application name. |
|
String |
Yes |
The name of the deployment configuration. |
|
String |
Yes |
The name of the deployment group. |
|
String |
Yes |
Additional information about the deployment. |
|
String |
Yes |
The type of application revision. |
|
String |
No |
The configuration for an automatic rollback, added when a deployment is created. |
|
JSON |
No |
The event type or types that trigger a rollback. |
|
String |
No |
How AWS CodeDeploy handles files that already exist in a deployment target location but were not part of the previous successful deployment. |
|
Boolean |
No |
If an ApplicationStop, BeforeBlockTraffic, or AfterBlockTraffic deployment lifecycle event on an instance fails, and |
|
JSON |
No |
A list of alarms configured for the deployment or deployment group. |
|
String |
No |
Indicates whether the alarm configuration is enabled. |
|
String |
No |
The content of an AppSpec file for an AWS Lambda or Amazon ECS deployment. The content is formatted as JSON or YAML and stored as a RawString. |
|
String |
No |
The SHA256 hash value of the revision content. |
|
String |
No |
The content of a string input for an AWS Lambda or Amazon ECS deployment. The content is formatted as JSON or YAML and stored as a RawString. |
|
String |
No |
The SHA256 hash value of the revision content. |
|
String |
No |
The SHA1 commit ID of the GitHub commit that represents the bundled artifacts for the application revision. |
|
String |
No |
The GitHub account and repository pair that stores a reference to the commit that represents the bundled artifacts for the application revision. |
|
String |
No |
The name of the Amazon S3 bucket where the application revision is stored. |
|
String |
No |
The file type of the application revision. |
|
String |
No |
The name of the Amazon S3 object that represents the bundled artifacts for the application revision. |
|
String |
No |
The specific version of the Amazon S3 object that represents the bundled artifacts for the application revision. |
|
JSON |
No |
The names of one or more Auto Scaling groups to identify a replacement environment for a blue or green deployment. |
|
JSON |
No |
The tag filter key, type, and value used to identify Amazon EC2 instances in a replacement environment for a blue or green deployment. |
|
JSON |
No |
The information about the groups of Amazon EC2 instance tags. |
Usage example
In your YAML file, add:
- id: login name: Configure AWS credentials uses: https://github.com/cloudbees-io/configure-aws-credentials@v1 with: aws-region: us-east-1 aws-access-key-id: ${{ secrets.AWS_CODEDEPLOY_ACTIONS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_CODEDEPLOY_ACTIONS_SECRET_ACCESS_KEY }} - name: Create AWS CodeDeploy deployment uses: https://github.com/cloudbees-io/aws-codedeploy-invoke-deployment@v1 with: application-name: 'cb-sample-app' description: "CodeDeploy-ec2-deployment" deployment-group-name: 'cd-deployment-grp' revision-type: 'S3' s3-bucket: 'cb-codedeploy' s3-key: 'Archive.zip' s3-bundle-type: 'zip' deployment-config-name: 'CodeDeployDefault.OneAtATime' target-instance-tag-filters: '[{"Key":"Name","Type":"KEY_AND_VALUE","Value":"cb-codedeploy-web"}]'
Create or update a Lambda function
Use the cloudbees-io/lambda-create-function action to create or update a function in AWS Lambda without provisioning or managing servers.
| All CloudBees action repositories are listed at CloudBees, Inc. on GitHub. |
Inputs
| Input name | Data type | Required? | Description |
|---|---|---|---|
|
String |
Yes |
The AWS Lambda function name. |
|
String |
Yes |
The Identity and Access Management (IAM) name of the function’s execution role, in ARN format. |
|
String |
No |
The type of build input artifact.
Options are |
|
String |
Required only if using an image ( |
The code image resource, such as the Amazon ECR repository URI. |
|
String |
Required only if using a ZIP file ( |
The path to the ZIP file of the code to be uploaded. |
|
String |
Required only if using a ZIP file ( |
The method name in uploaded code that Lambda calls to run the function. |
|
String |
Required only if using a ZIP file ( |
The Lambda function runtime. |
|
String |
Required only if using an Amazon S3 bucket. |
The Amazon S3 bucket name. |
|
String |
Required only if using an Amazon S3 bucket. |
The Amazon S3 bucket object name. |
|
JSON string |
No |
The instruction set architecture that the function supports. |
|
String |
No |
The Amazon Resource Name (ARN) for a code-signing configuration. |
|
JSON string |
No |
The location where the Lambda function sends asynchronous events that fail to process. |
|
String |
No |
The Lambda function description. |
|
Boolean |
No |
Default is |
|
JSON string |
No |
The environment variables accessible from the function code during execution. |
|
JSON string |
No |
The size of the Lambda function |
|
JSON string |
No |
The Amazon EFS file system connection settings. |
|
JSON string |
No |
The container image configuration values that override the container image Dockerfile values. |
|
String |
No |
The ARN of the AWS Key Management Service (KMS) customer-managed key used to encrypt your function’s environment variables. |
|
JSON string |
No |
The list of function layers to add to the Lambda function’s execution environment. |
|
Integer |
No |
The amount of memory available to the Lambda function at runtime. |
|
Boolean |
No |
Default is |
|
String |
No |
The latest updated revision ID. If specified, the Lambda function is only updated if the revision ID matches the latest updated revision ID. |
|
String |
No |
The Amazon S3 bucket object version. |
|
JSON string |
No |
The SnapStart configuration to run the Lambda function with a pre-initialized snapshot. |
|
JSON string |
No |
The Lambda function tag list. |
|
Integer |
No |
The allowed amount of time, in seconds, that a Lambda function runs before it is stopped. |
|
JSON string |
No |
The AWS X-Ray tracing configuration in the Lambda function. To sample and record incoming requests, enable X-Ray active tracing in the Lambda functions console. |
|
JSON string |
No |
The VPC security groups and subnets for network connectivity to AWS resources. |
Usage examples
The following examples show how to create or update a Lambda function using an ECR image, an Amazon S3 bucket, or a local ZIP file.
Using an ECR image
- name: Create or update AWS lambda function with ECR id: createOrUpdateLambdaFunctionWithECR uses: https://github.com/cloudbees-io/lambda-create-function@v1 with: iam-role-arn: arn:aws:iam::123456789012:role/my-lambda-actions function-name: my-function package-type: Image code-image: 123456789012.dkr.ecr.us-west-2.amazonaws.com/hello-world-lambda:v1 architectures: '["x86_64"]'
Using an Amazon S3 bucket
- name: Create or update an AWS lambda function with S3 id: createOrUpdateLambdaFunctionWithS3 uses: https://github.com/cloudbees-io/lambda-create-function@v1 with: iam-role-arn: arn:aws:iam::123456789012:role/my-lambda-actions function-name: my-function package-type: Zip handler: bootstrap s3-bucket: my-lambda-actions s3-key: hello-lambda/bootstrap.zip s3-object-version: "" architectures: '["x86_64"]' runtime: provided.al2
Using a local ZIP file
- name: Create or update AWS lambda function with ZIP file id: createOrUpdateLambdaFunctionWithZip uses: https://github.com/cloudbees-io/lambda-create-function@v1 with: iam-role-arn: arn:aws:iam::123456789012:role/my-lambda-actions function-name: my-function package-type: Zip handler: bootstrap code-zip: ${{ cloudbees.workspace }}/bootstrap.zip architectures: '["x86_64", "arm64"]' runtime: provided.al2
Invoke a Lambda function
Use the cloudbees-io/lambda-invoke-function action to invoke an existing function in AWS Lambda.
| All CloudBees action repositories are listed at CloudBees, Inc. on GitHub. |