Skip to content

Commit 9e7ec2a

Browse files
committed
Update to Terraform module
1 parent 230bd49 commit 9e7ec2a

File tree

10 files changed

+211
-47
lines changed

10 files changed

+211
-47
lines changed

.github/workflows/container.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Main build pipeline that verifies, builds, and deploys the software
2+
name: Build Docker image (ghcr.io)
3+
# Events that trigger the workflow
4+
on:
5+
# Run workflow manually from the Actions tab
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
type: string
10+
description: Application version to build container image for
11+
required: true
12+
13+
# Only allow 1 execution of this workflow to be running at any given time per-branch.
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
# Environment variables
19+
env:
20+
IMAGE_NAME: ${{ github.repository }}
21+
POETRY_VERSION: "2.1.1"
22+
PYTHON_VERSION: "3.10"
23+
REGISTRY: ghcr.io
24+
25+
jobs:
26+
container:
27+
name: Build container image
28+
# The type of runner that the job will run on
29+
runs-on: ubuntu-latest
30+
env:
31+
APP_VERSION: ${{ github.event.inputs.version }}
32+
steps:
33+
# Check out GitHub repo
34+
- uses: actions/checkout@v4
35+
with:
36+
repository: ${{ github.repository }}
37+
38+
# ghcr.io container image
39+
- name: Log in to the Container registry
40+
uses: docker/login-action@v3
41+
with:
42+
registry: ${{ env.REGISTRY }}
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Extract metadata (tags, labels) for Docker
47+
id: meta
48+
uses: docker/metadata-action@v5
49+
with:
50+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
51+
tags: |
52+
type=pep440,pattern={{version}},value=${{ env.APP_VERSION }}
53+
flavor: |
54+
latest=true
55+
56+
- name: Build and push Docker image
57+
uses: docker/build-push-action@v5
58+
with:
59+
context: .
60+
file: Dockerfile
61+
push: true
62+
pull: true
63+
tags: ${{ steps.meta.outputs.tags }}
64+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/deploy.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ on:
2121
- DEV1
2222
- DEV2
2323
- OPS
24+
version:
25+
type: string
26+
description: Application version to build container image for
27+
required: true
2428

2529
# Environment variables
2630
env:
@@ -130,6 +134,7 @@ jobs:
130134

131135
- name: Define TF_VAR values
132136
run: |
137+
echo "TF_VAR_app_version=${{ github.event.inputs.version }}" >> $GITHUB_ENV
133138
echo "TF_VAR_environment=$TARGET_ENV" >> $GITHUB_ENV
134139
echo "TF_VAR_prefix=$PREFIX_ENV" >> $GITHUB_ENV
135140
echo "TF_IN_AUTOMATION=true" >> $GITHUB_ENV

.github/workflows/release.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Main build pipeline that verifies, builds, and deploys the software
2+
name: Create a release
3+
# Events that trigger the workflow
4+
on:
5+
# Run workflow manually from the Actions tab
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
type: string
10+
description: Application version to build container image for
11+
required: true
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Create GH release
18+
uses: ncipollo/release-action@v1
19+
with:
20+
generateReleaseNotes: true
21+
name: ${{ github.event.inputs.version }}
22+
tag: ${{ github.event.inputs.version }}

terraform/.terraform.lock.hcl

Lines changed: 17 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

terraform/main.tf

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,34 @@ terraform {
55
required_providers {
66
aws = {
77
source = "hashicorp/aws"
8-
version = "~> 4.0"
8+
version = "~> 5.0"
99
}
1010
}
1111
}
1212

13-
# Configure the AWS Provider
1413
provider "aws" {
1514
default_tags {
1615
tags = local.default_tags
1716
}
18-
region = var.aws_region
17+
region = var.aws_region
1918
}
2019

21-
# Data sources
2220
data "aws_caller_identity" "current" {}
2321

24-
data "aws_cloudwatch_log_group" "cw_log_group" {
25-
name = "/aws/batch/job/${var.prefix}-metroman/"
26-
}
27-
28-
data "aws_efs_file_system" "aws_efs_input" {
29-
creation_token = "${var.prefix}-input"
30-
}
31-
32-
data "aws_efs_file_system" "aws_efs_flpe" {
33-
creation_token = "${var.prefix}-flpe"
34-
}
35-
36-
data "aws_iam_role" "job_role" {
37-
name = "${var.prefix}-batch-job-role"
38-
}
39-
40-
data "aws_iam_role" "exe_role" {
41-
name = "${var.prefix}-ecs-exe-task-role"
42-
}
43-
44-
# Local variables
4522
locals {
46-
account_id = data.aws_caller_identity.current.account_id
23+
account_id = sensitive(data.aws_caller_identity.current.account_id)
4724
default_tags = length(var.default_tags) == 0 ? {
4825
application : var.app_name,
4926
environment : lower(var.environment),
5027
version : var.app_version
5128
} : var.default_tags
29+
}
30+
31+
module "confluence-input" {
32+
source = "./modules/metroman"
33+
app_name = var.app_name
34+
app_version = var.app_version
35+
aws_region = var.aws_region
36+
environment = var.environment
37+
prefix = var.prefix
5238
}

terraform/modules/metroman/.terraform.lock.hcl

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

terraform/modules/metroman/main.tf

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Data sources
2+
data "aws_caller_identity" "current" {}
3+
4+
data "aws_cloudwatch_log_group" "cw_log_group" {
5+
name = "/aws/batch/job/${var.prefix}-metroman/"
6+
}
7+
8+
data "aws_efs_file_system" "aws_efs_input" {
9+
creation_token = "${var.prefix}-input"
10+
}
11+
12+
data "aws_efs_file_system" "aws_efs_flpe" {
13+
creation_token = "${var.prefix}-flpe"
14+
}
15+
16+
data "aws_iam_role" "job_role" {
17+
name = "${var.prefix}-batch-job-role"
18+
}
19+
20+
data "aws_iam_role" "exe_role" {
21+
name = "${var.prefix}-ecs-exe-task-role"
22+
}
23+
24+
# Local variables
25+
locals {
26+
account_id = data.aws_caller_identity.current.account_id
27+
default_tags = length(var.default_tags) == 0 ? {
28+
application : var.app_name,
29+
environment : lower(var.environment),
30+
version : var.app_version
31+
} : var.default_tags
32+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
variable "app_name" {
2+
type = string
3+
description = "Application name"
4+
default = "confluence"
5+
}
6+
7+
variable "app_version" {
8+
type = string
9+
description = "The application version number"
10+
}
11+
12+
variable "aws_region" {
13+
type = string
14+
description = "AWS region to deploy to"
15+
default = "us-west-2"
16+
}
17+
18+
variable "default_tags" {
19+
type = map(string)
20+
default = {}
21+
}
22+
23+
variable "environment" {
24+
type = string
25+
description = "The environment in which to deploy to"
26+
}
27+
28+
variable "prefix" {
29+
type = string
30+
description = "Prefix to add to all AWS resources as a unique identifier"
31+
}

terraform/variables.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
variable "app_name" {
22
type = string
33
description = "Application name"
4-
default = "generate"
4+
default = "confluence"
55
}
66

77
variable "app_version" {
8-
type = number
8+
type = string
99
description = "The application version number"
10-
default = 0.1
1110
}
1211

1312
variable "aws_region" {

0 commit comments

Comments
 (0)