Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tf test #3

Merged
merged 9 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
Loading