Skip to content

Deploying the Telegram bot on AWS #23

Deploying the Telegram bot on AWS

Deploying the Telegram bot on AWS #23

Workflow file for this run

name: Deploying the Telegram bot on AWS
on:
workflow_dispatch:
env:
AWS_REGION: ${{ vars.AWS_REGION }}
TERRAFORM_PATH: "./terraform/"
LOGGING_LEVEL: "DEBUG"
LOG_GROUP_RETENTION_PERIOD: 5
permissions:
contents: read
jobs:
terraform:
name: 'Deploy the bot on AWS'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Replace Region in Provider section of Terraform
run: sed -i 's/us-east-1/${{ env.AWS_REGION }}/g' $TERRAFORM_PATH/00-provider.tf
- name: Terraform Init
run: terraform -chdir=$TERRAFORM_PATH init
- name: Terraform Format
run: terraform -chdir=$TERRAFORM_PATH fmt -check
- name: Terraform Plan
run: terraform -chdir=$TERRAFORM_PATH plan -input=false -var "aws_region=${{ env.AWS_REGION }}" -var="bot_token=${{ secrets.BOT_TOKEN }}" -var="logging_level=${{ env.LOGGING_LEVEL }}" -var "log_group_retention_period=${{ env.LOG_GROUP_RETENTION_PERIOD }}"
- name: Terraform Apply
run: terraform -chdir=$TERRAFORM_PATH apply -auto-approve -input=false -var "aws_region=${{ env.AWS_REGION }}" -var="bot_token=${{ secrets.BOT_TOKEN }}" -var="logging_level=${{ env.LOGGING_LEVEL }}" -var "log_group_retention_period=${{ env.LOG_GROUP_RETENTION_PERIOD }}"