-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62b6e30
commit a82d441
Showing
3 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,7 @@ | ||
name: Pipeline de Deploy Batch | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
permissions: | ||
id-token: write | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Pipeline de Destroy Lambda | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref }} | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
role-to-assume: "arn:aws:iam::340752815603:role/oidc-github-framework-eml-role" | ||
role-session-name: GitHub_to_AWS_via_FederatedOIDC | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
- name: Setup Terraform | ||
uses: hashicorp/setup-terraform@v3 | ||
with: | ||
terraform_version: 1.8.0 | ||
|
||
- name: Destroy infrastructure | ||
run: | | ||
chmod +x deployment/scripts/destroy_infra_lambda.sh | ||
./deployment/scripts/destroy_infra_lambda.sh ${{ env.AWS_REGION }} | ||
env: | ||
REPO_NAME: "prediction-eml" | ||
AWS_REGION: "us-east-1" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text) | ||
BUCKET_NAME="$ACCOUNT_ID-prediction-eml" | ||
AWS_REGION=$1 | ||
|
||
# Verifica se o bucket existe | ||
if aws s3api head-bucket --bucket "$BUCKET_NAME" 2>/dev/null; then | ||
echo "O bucket '$BUCKET_NAME' já existe." | ||
else | ||
# Se o bucket não existir, cria o bucket | ||
aws s3api create-bucket --bucket "$BUCKET_NAME" --region us-east-1 | ||
echo "Bucket '$BUCKET_NAME' criado com sucesso." | ||
fi | ||
|
||
# Inicializa o Terraform | ||
terraform -chdir="deployment/infrastructure/terraform-lambda" init -backend-config="bucket=$BUCKET_NAME" -backend-config="region=$AWS_REGION" | ||
|
||
# Comando para destruir a infraestrutura | ||
terraform -chdir="deployment/infrastructure/terraform-lambda" destroy -auto-approve |