Skip to content

Commit

Permalink
Merge pull request #3 from pavelnikolov/tf-test
Browse files Browse the repository at this point in the history
tf test
  • Loading branch information
pavelnikolov authored Jul 25, 2024
2 parents d824e70 + ff92597 commit 10eb916
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ client.Dockerfile
server.Dockerfile
README.md
docker-compose.yml
target/
target/
terraform/.terraform
terraform/terraform.tfstate
terraform
3 changes: 2 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Create and publish a Docker image

on:
push:
branches: ['main']
branches:
- 'main'

env:
REGISTRY: ghcr.io
Expand Down
11 changes: 9 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@ name: Build

on:
push:
branches: [ "main" ]
branches:
- 'main'
pull_request:
branches: [ "main" ]
paths:
- 'src/**'
- 'tests/**'
- 'Cargo.toml'
- 'Cargo.lock'
- '.github/workflows/rust.yml'
- 'build.rs'

env:
CARGO_TERM_COLOR: always
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/terraform-apply.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: "Network Terraform Apply"

on:
push:
branches:
- main
paths:
- 'terraform/**'
workflow_dispatch:

env:
TF_WORKSPACE: "default"
CONFIG_DIRECTORY: "./terraform"

jobs:
terraform:
name: "Network Terraform Plan & Apply"
runs-on: ubuntu-latest

defaults:
run:
working-directory: ${{ env.CONFIG_DIRECTORY }}
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4

- name: Assume AWS Credentials
id: assume
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ secrets.AWS_REGION }}
role-session-name: ${{ github.actor }}
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}

- uses: hashicorp/setup-terraform@v3

- 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 -no-color

- name: Terraform Plan
id: plan
run: terraform plan -no-color -out=tf.plan

- name: Terraform Apply
run: terraform apply -auto-approve tf.plan
6 changes: 5 additions & 1 deletion .github/workflows/terraform-plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
env:
TF_WORKSPACE: "default"
CONFIG_DIRECTORY: "./terraform"
AWS_REGION: ${{ secrets.AWS_REGION }}

jobs:
terraform:
Expand All @@ -21,16 +22,19 @@ jobs:
contents: read
id-token: write
pull-requests: write

env:
TF_VAR_state_bucket: ${{ secrets.TF_VAR_STATE_BUCKET }}
steps:
- uses: actions/checkout@v4

- name: Assume AWS Credentials
id: assume
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ secrets.AWS_REGION }}
role-session-name: ${{ github.actor }}
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_REGION }}

- uses: hashicorp/setup-terraform@v3

Expand Down
15 changes: 15 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}

backend "s3" {
bucket = "zkpauth-9d8hh34135a5"
key = "terraform.tfstate"
}
}

provider "aws" {
region = var.aws_region
}


resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
}
Expand Down
2 changes: 1 addition & 1 deletion terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ variable "aws_region" {
description = "AWS region"
default = "eu-central-1"
type = string
}
}

0 comments on commit 10eb916

Please sign in to comment.