Provisioning of the AWS infraestructure #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Provisioning of the AWS infraestructure | |
# Será executada as atividade abaixo de forma manual | |
on: | |
workflow_dispatch: | |
jobs: | |
provisioning: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: cloud_infra/terraform | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Configure Public SSH key | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.SSH_PUBLIC_KEY }}" > ~/.ssh/id_rsa.pub | |
chmod 600 ~/.ssh/id_rsa.pub | |
- name: Configure AWS credentials | |
run: | | |
mkdir -p ~/.aws | |
echo '[default]' > ~/.aws/credentials | |
echo 'aws_access_key_id = ${{ secrets.AWS_ACCESS_KEY_ID }}' >> ~/.aws/credentials | |
echo 'aws_secret_access_key = ${{ secrets.AWS_SECRET_ACCESS_KEY }}' >> ~/.aws/credentials | |
chmod 600 ~/.aws/credentials | |
- uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: "1.7.5" | |
- name: Terraform initialization (e.g., download provider plugins) | |
run: terraform init | |
- name: Validation of Terraform script | |
run: terraform validate | |
- name: Generate Terraform execution plan | |
run: terraform plan -out=tfplan | |
- name: Create infraestructure on AWS | |
run: terraform apply "tfplan" |