Skip to content

Commit

Permalink
Introduce IaC
Browse files Browse the repository at this point in the history
  • Loading branch information
wellyfrs committed Mar 17, 2024
1 parent e811077 commit 5daf037
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 12 deletions.
12 changes: 0 additions & 12 deletions .editorconfig

This file was deleted.

66 changes: 66 additions & 0 deletions .github/workflows/provisioning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: "Provisioning"

on:
push:
branches:
- main
paths:
- .github/workflows/provisioning.yml
- 'terraform/**'
pull_request:
branches:
- main
paths:
- .github/workflows/provisioning.yml
- 'terraform/**'

jobs:
provisioning:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./terraform
permissions:
id-token: write
contents: read
pull-requests: write

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::202062340677:role/TechChallengeLambdaDeployer
aws-region: ${{ vars.AWS_REGION }}

- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
cli_config_credentials_token: ${{ secrets.TF_CLOUD_USER_API_TOKEN }}

- name: Terraform fmt
id: fmt
run: terraform fmt -check
continue-on-error: true

- name: Terraform Init
id: init
run: terraform init

- name: Terraform Validate
id: validate
run: terraform validate

- name: Terraform Plan
id: plan
run: terraform plan

- name: Check Errors
if: steps.plan.outcome == 'failure'
run: exit 1

- name: Terraform Apply
#if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: terraform apply -auto-approve -input=false
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Bleno Claus, Giovanni di Luca, Mateus Albino, Wellyson Freitas

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
File renamed without changes.
12 changes: 12 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module "lambda_function" {
source = "terraform-aws-modules/lambda/aws"
version = "7.2.2"

function_name = "sign-up"
handler = "index.lambda_handler"
runtime = "python3.12"

source_path = "../src"

tags = var.tags
}
18 changes: 18 additions & 0 deletions terraform/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.36"
}
}

backend "s3" {
bucket = "fiap-3soat-g15-infra-lambda-sign-up-state"
key = "live/terraform.tfstate"
region = "us-east-1"
}
}

provider "aws" {
region = var.region
}
7 changes: 7 additions & 0 deletions terraform/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
region = "us-east-1"

tags = {
managed_by_terraform = true
}

account_id = "202062340677"
11 changes: 11 additions & 0 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
variable "region" {
type = string
}

variable "tags" {
type = map(string)
}

variable "account_id" {
type = string
}

0 comments on commit 5daf037

Please sign in to comment.