Skip to content

Commit

Permalink
Merge pull request #4 from OneideLuizSchneider/v1.0
Browse files Browse the repository at this point in the history
V1.0
  • Loading branch information
OneideLuizSchneider authored Jul 4, 2022
2 parents 05df7cd + 1f84b0f commit 018912a
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 57 deletions.
103 changes: 52 additions & 51 deletions .github/workflows/terraform-plan.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,52 @@
name: CI

# Trigger when a pull request is received
on:
pull_request:

# Allows you to run this workflow manually from the Actions tab
#workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
terraform:
runs-on: ubuntu-latest
env:
working-directory: terraform
TF_WORKSPACE: my-workspace
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Check out code
uses: actions/checkout@v2

- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: 0.14.6

- name: Terraform Fmt
id: fmt
run: cd terraform && terraform fmt -check -diff
continue-on-error: true

- name: Terraform Init
id: init
run: cd terraform && terraform init
continue-on-error: true

- name: Terraform Validate
id: validate
run: cd terraform && terraform validate -no-color
continue-on-error: true

- name: Terraform Plan
id: plan
run: cd terraform && terraform plan -no-color
continue-on-error: true
#name: CI
#
## Trigger when a pull request is received
#on:
# pull_request:
#
# # Allows you to run this workflow manually from the Actions tab
# #workflow_dispatch:
#
## A workflow run is made up of one or more jobs that can run sequentially or in parallel
#jobs:
# terraform:
# runs-on: ubuntu-latest
# env:
# working-directory: terraform
# TF_WORKSPACE: my-workspace
# steps:
# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v1
# with:
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# aws-region: ${{ secrets.AWS_REGION }}
#
# - name: Check out code
# uses: actions/checkout@v2
#
# - name: Setup Terraform
# uses: hashicorp/setup-terraform@v1
# with:
# terraform_version: 0.14.6
#
# - name: Terraform Fmt
# id: fmt
# run: cd terraform && terraform fmt -check -diff
# continue-on-error: true
#
# - name: Terraform Init
# id: init
# run: cd terraform && terraform init
# continue-on-error: true
#
# - name: Terraform Validate
# id: validate
# run: cd terraform && terraform validate -no-color
# continue-on-error: true
#
# - name: Terraform Plan
# id: plan
# run: cd terraform && terraform plan -no-color
# continue-on-error: true
#
10 changes: 10 additions & 0 deletions terraform/iam-roles-node-groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ resource "aws_iam_role_policy_attachment" "node-group-AmazonEC2ContainerRegistry
role = aws_iam_role.node-group.name
}

resource "aws_iam_role_policy_attachment" "node-group-AmazonSSMManagedInstanceCore" {
policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
role = aws_iam_role.node-group.name
}

resource "aws_iam_role_policy_attachment" "node-group-CloudWatchAgentServerPolicy" {
policy_arn = "arn:aws:iam::aws:policy/CloudWatchAgentServerPolicy"
role = aws_iam_role.node-group.name
}

resource "aws_iam_role_policy" "node-group-ClusterAutoscalerPolicy" {
name = "eks-cluster-auto-scaler"
role = aws_iam_role.node-group.id
Expand Down
4 changes: 3 additions & 1 deletion terraform/node-group.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ resource "aws_eks_node_group" "private" {
depends_on = [
aws_iam_role_policy_attachment.node-group-AmazonEKSWorkerNodePolicy,
aws_iam_role_policy_attachment.node-group-AmazonEKS_CNI_Policy,
aws_iam_role_policy_attachment.node-group-AmazonEC2ContainerRegistryReadOnly
aws_iam_role_policy_attachment.node-group-AmazonEC2ContainerRegistryReadOnly,
aws_iam_role_policy_attachment.node-group-AmazonSSMManagedInstanceCore,
aws_iam_role_policy_attachment.node-group-CloudWatchAgentServerPolicy
]

tags = {
Expand Down
3 changes: 3 additions & 0 deletions terraform/main.tf → terraform/provider.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
provider "aws" {
version = "~> 3.37"

region = local.region
access_key = local.access_key
secret_key = local.secret_key

}
15 changes: 10 additions & 5 deletions terraform/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ terraform {

variable "env" {
type = string
default = "hml"
default = "staging"
}

variable "cluster_version" {
type = string
default = "v2"
}

variable "eks_cluster_name" {
type = string
default = "eks-cluster-v2"
default = "eks-cluster-name"
}

locals{
Expand All @@ -21,11 +26,11 @@ locals{
subnets = ["..."]
internal_ip_range = "0.0.0.0/0"

eks_version = "..."
cluster_name = var.eks_cluster_name
eks_version = "1.22"
cluster_name = "${var.eks_cluster_name}-${var.env}-${var.cluster_version}"
cluster_enabled_log_types = ["api", "audit", "authenticator", "controllerManager", "scheduler"]
asg_desired_capacity = 1
asg_max_size = 3
asg_max_size = 2
asg_min_size = 1
instance_type = ["..."]
}

0 comments on commit 018912a

Please sign in to comment.