Skip to content

Commit 9e324bf

Browse files
committed
moving eks cluster out of single workspace
1 parent 0bc2bc7 commit 9e324bf

File tree

33 files changed

+192
-70
lines changed

33 files changed

+192
-70
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ on:
55
workflow_dispatch:
66

77
jobs:
8-
terraform-apply:
9-
uses: ./.github/workflows/terraform-apply.yml
8+
terraform-apply-eks:
9+
uses: ./.github/workflows/terraform-apply-eks.yml
10+
permissions:
11+
contents: read
12+
secrets: inherit
13+
terraform-apply-pipelines:
14+
needs: terraform-apply-eks
15+
uses: ./.github/workflows/terraform-apply-pipelines.yml
1016
permissions:
1117
contents: read
1218
secrets: inherit
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: "Terraform Apply"
2+
3+
on:
4+
workflow_call:
5+
6+
env:
7+
TF_CLOUD_ORGANIZATION: "DSB"
8+
TF_API_TOKEN: "${{ secrets.TF_API_TOKEN }}"
9+
TF_WORKSPACE: "dsb-aws-devsecops-pipelines"
10+
CONFIG_DIRECTORY: "./terraform/eks-cluster"
11+
12+
jobs:
13+
terraform:
14+
name: "Terraform Apply"
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Upload Configuration
23+
uses: hashicorp/tfc-workflows-github/actions/[email protected]
24+
id: apply-upload
25+
with:
26+
workspace: ${{ env.TF_WORKSPACE }}
27+
directory: ${{ env.CONFIG_DIRECTORY }}
28+
29+
- name: Create Apply Run
30+
uses: hashicorp/tfc-workflows-github/actions/[email protected]
31+
id: apply-run
32+
with:
33+
workspace: ${{ env.TF_WORKSPACE }}
34+
configuration_version: ${{ steps.apply-upload.outputs.configuration_version_id }}
35+
36+
- name: Apply
37+
uses: hashicorp/tfc-workflows-github/actions/[email protected]
38+
if: fromJSON(steps.apply-run.outputs.payload).data.attributes.actions.IsConfirmable
39+
id: apply
40+
with:
41+
run: ${{ steps.apply-run.outputs.run_id }}
42+
comment: "Apply Run from GitHub Actions CI ${{ github.sha }}"

.github/workflows/terraform-apply.yml renamed to .github/workflows/terraform-apply-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ env:
77
TF_CLOUD_ORGANIZATION: "DSB"
88
TF_API_TOKEN: "${{ secrets.TF_API_TOKEN }}"
99
TF_WORKSPACE: "dsb-aws-devsecops-pipelines"
10-
CONFIG_DIRECTORY: "./terraform"
10+
CONFIG_DIRECTORY: "./terraform/pipelines"
1111

1212
jobs:
1313
terraform:

terraform/eks-cluster/data.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data "aws_caller_identity" "current" {}

terraform/eks-cluster/main.tf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Default Networking Configuration
2+
resource "aws_default_subnet" "default_subnet_a" {
3+
availability_zone = "${var.region}a"
4+
}
5+
6+
resource "aws_default_subnet" "default_subnet_b" {
7+
availability_zone = "${var.region}b"
8+
}
9+
10+
# EKS Cluster
11+
module "default_cluster" {
12+
source = "./modules/eks"
13+
cluster_name = "${var.resource_prefix}-devsecops-cluster"
14+
subnet_ids = [
15+
aws_default_subnet.default_subnet_a.id,
16+
aws_default_subnet.default_subnet_b.id
17+
]
18+
node_group_min_size = 1
19+
node_group_max_size = 3
20+
node_group_desired_capacity = 2
21+
instance_types = ["t3.medium"]
22+
node_group_disk_size = 20
23+
}
File renamed without changes.
File renamed without changes.

terraform/eks-cluster/provider.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
provider "aws" {
2+
region = var.region
3+
}
4+
5+
terraform {
6+
cloud {
7+
organization = "DSB"
8+
9+
workspaces {
10+
name = "dsb-aws-devsecops-eks-cluster"
11+
}
12+
}
13+
}

terraform/eks-cluster/variables.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
variable "resource_prefix" {
2+
type = string
3+
description = "Prefix for AWS Resources"
4+
default = "dsb"
5+
}
6+
7+
variable "region" {
8+
type = string
9+
description = "AWS Region"
10+
default = "us-east-1"
11+
}

0 commit comments

Comments
 (0)