Skip to content

Commit 0283029

Browse files
Create aws-elastic-beanstalk-service.md
Create aws-elastic-beanstalk-service.md in the DeployToThirdPartyPlatforns GitHub Actions page
1 parent 12e8511 commit 0283029

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
title: Deploying to AWS Elastic Beanstalk
3+
shortTitle: AWS Elastic Beanstalk
4+
intro: Learn how to deploy a project to AWS Elastic Beanstalk as part of a continuous deployment (CD) workflow.
5+
versions:
6+
fpt: '*'
7+
ghes: '*'
8+
ghec: '*'
9+
topics:
10+
- CD
11+
- AWS Elastic Beanstalk
12+
---
13+
14+
## Prerequisites
15+
16+
Before creating your {% data variables.product.prodname_actions %} workflow, you will first need to complete the following setup steps for AWS Elastic Beanstalk:
17+
18+
1. **Configure AWS Authentication**. You can use either OpenID Connect (OIDC) or static credentials:
19+
20+
**Option A: OpenID Connect (OIDC) - Recommended**
21+
22+
Create an OIDC identity provider and IAM role in your AWS account. For detailed instructions, see the [AWS Elastic Beanstalk Deploy Action documentation](https://github.com/aws-actions/aws-elasticbeanstalk-deploy#step-1-configure-aws-authentication).
23+
24+
**Option B: Static Credentials**
25+
26+
Create an IAM user with programmatic access and note the access key ID and secret access key.
27+
28+
1. **Attach Required Permissions**. Your IAM role or user needs:
29+
- Elastic Beanstalk permissions (use the AWS managed policy `AdministratorAccess-AWSElasticBeanstalk` or create a custom policy)
30+
- S3 permissions for the deployment bucket. The action uses `elasticbeanstalk-{region}-{accountId}` by default, or you can specify a custom bucket name using the `s3-bucket-name` input
31+
32+
1. **Create IAM Roles for Elastic Beanstalk**:
33+
- **Instance Profile** (`aws-elasticbeanstalk-ec2-role`): Allows EC2 instances to upload logs and download application versions
34+
- **Service Role** (`aws-elasticbeanstalk-service-role`): Allows Elastic Beanstalk to manage AWS resources
35+
36+
For detailed instructions on creating these roles, see [Managing Elastic Beanstalk Instance Profiles](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/iam-instanceprofile.html) and [Managing Elastic Beanstalk Service Roles](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/iam-servicerole.html).
37+
38+
1. **Create {% data variables.product.prodname_actions %} secrets**:
39+
- For OIDC: `AWS_ROLE_TO_ASSUME` (ARN of your IAM role)
40+
- For static credentials: `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`
41+
42+
For more information on creating secrets for {% data variables.product.prodname_actions %}, see [AUTOTITLE](/actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository).
43+
44+
## Creating the workflow
45+
46+
Once you've completed the prerequisites, you can proceed with creating the workflow.
47+
48+
The following example workflow demonstrates how to deploy an application to AWS Elastic Beanstalk. The action automatically creates the application and environment if they don't exist, uploads your deployment package to S3, and deploys it to Elastic Beanstalk.
49+
50+
Ensure that you provide your own values for all the variables in the `env` key of the workflow.
51+
52+
{% data reusables.actions.delete-env-key %}
53+
54+
```yaml copy
55+
{% data reusables.actions.actions-not-certified-by-github-comment %}
56+
57+
{% data reusables.actions.actions-use-sha-pinning-comment %}
58+
59+
name: Deploy to AWS Elastic Beanstalk
60+
61+
on:
62+
push:
63+
branches: [ main ]
64+
65+
env:
66+
AWS_REGION: MY_AWS_REGION # set this to your preferred AWS region, e.g. us-west-1
67+
APPLICATION_NAME: MY_APPLICATION_NAME # set this to your Elastic Beanstalk application name
68+
ENVIRONMENT_NAME: MY_ENVIRONMENT_NAME # set this to your Elastic Beanstalk environment name
69+
SOLUTION_STACK_NAME: MY_SOLUTION_STACK_NAME # set this to your platform version, e.g. "64bit Amazon Linux 2023 v4.9.2 running Python 3.14"
70+
71+
jobs:
72+
deploy:
73+
name: Deploy
74+
runs-on: ubuntu-latest
75+
environment: production
76+
permissions:
77+
id-token: write
78+
contents: read
79+
80+
steps:
81+
- name: Checkout
82+
uses: {% data reusables.actions.action-checkout %}
83+
84+
- name: Configure AWS credentials
85+
uses: aws-actions/configure-aws-credentials@v4
86+
with:
87+
role-to-assume: {% raw %}${{ secrets.AWS_ROLE_TO_ASSUME }}{% endraw %}
88+
aws-region: {% raw %}${{ env.AWS_REGION }}{% endraw %}
89+
90+
- name: Deploy to Elastic Beanstalk
91+
uses: aws-actions/aws-elasticbeanstalk-deploy@v1.0.0
92+
with:
93+
aws-region: {% raw %}${{ env.AWS_REGION }}{% endraw %}
94+
application-name: {% raw %}${{ env.APPLICATION_NAME }}{% endraw %}
95+
environment-name: {% raw %}${{ env.ENVIRONMENT_NAME }}{% endraw %}
96+
solution-stack-name: {% raw %}${{ env.SOLUTION_STACK_NAME }}{% endraw %}
97+
option-settings: |
98+
[
99+
{
100+
"Namespace": "aws:autoscaling:launchconfiguration",
101+
"OptionName": "IamInstanceProfile",
102+
"Value": "aws-elasticbeanstalk-ec2-role"
103+
},
104+
{
105+
"Namespace": "aws:elasticbeanstalk:environment",
106+
"OptionName": "ServiceRole",
107+
"Value": "aws-elasticbeanstalk-service-role"
108+
}
109+
]
110+
```
111+
112+
## Further reading
113+
114+
For more information on the services used in these examples, see the following documentation:
115+
116+
* [Security best practices in IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html) in the Amazon AWS documentation.
117+
* Official AWS [Configure AWS Credentials](https://github.com/aws-actions/configure-aws-credentials) action.
118+
* Official AWS [Elastic Beanstalk Deploy](https://github.com/aws-actions/aws-elasticbeanstalk-deploy) action.
119+
* [AWS Elastic Beanstalk Developer Guide](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/) in the Amazon AWS documentation.
120+
* [Elastic Beanstalk supported platforms](https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html) in the Amazon AWS documentation.

0 commit comments

Comments
 (0)