tf-beanstalk-dotnet-6
Terraform Beanstalk .NET 6
Adapt from here
Support Platform
License
MIT
Posted on July 28, 2023
Hello everyone!
I want to share how to automatically deploy .NET Web API to AWS Elastic Beanstalk. We will use GitHub Action as a deployment tool.
Please take a look at my strategy for the deployment process.
eb deploy --staged
Thanks to SAGAR/SHANKY for providing a great tutorial to provision AWS Elastic Beanstalk using Terraform. Please take a look into at their article. If you are curious my adoption, please take a look here.
If you are unsure how to use the Terraform, no worries. I would like to explain Terraform and AWS Elastic Beanstalk in the next article. You may provision AWS Elastic Beanstalk manually.
As mentioned at the beginning of my strategy, you may need to find these detailed steps of the Pipeline. You may need to check in the repository.
name: Deploy .NET
on:
push:
branches:
- main
jobs:
build_deploy:
name: Build & Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.x'
- name: Publish
run: dotnet publish WebApi -o site
- name: Generate deployment package
run: cd site; zip -r ../deploy.zip . -x '*.git*'; cd ..
- name: Upload .NET to artifact
uses: actions/upload-artifact@v3
with:
name: dotnet-zip
path: deploy.zip
- name: Setup EB CLI
run: |
python --version
pip --version
pip install awsebcli --upgrade --user
eb --version
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2 # More information on this action can be found below in the 'AWS Credentials' section
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ secrets.AWS_ROLE_SESSION_NAME }}
aws-region: 'ap-southeast-1'
- name: Deploy to EB
run: eb deploy dotnet-env-dev --staged
Additionally, I added a step of uploading to the artifact to archive the published result.
Room of improvement:
Thank you for reading my short article. Feel free to give feedback in the comment section. Have a great day!
Posted on July 28, 2023
Sign up to receive the latest update from our blog.