Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from commitdev/restructure-eks-and-k8s-terraform
Move kubernetes stuff out into separate runs, fix backend, fix some issues with generated code
- Loading branch information
Showing
16 changed files
with
202 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
templates/kubernetes/terraform/environments/development/kubernetes/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
terraform { | ||
backend "s3" { | ||
bucket = "project-{{ .Config.Name }}-terraform-state" | ||
key = "infrastructure/terraform/environments/development/main" | ||
encrypt = true | ||
region = "{{ .Config.Infrastructure.AWS.Region }}" | ||
dynamodb_table = "{{ .Config.Name }}-terraform-state-locks" | ||
} | ||
} | ||
|
||
# Instantiate the development environment | ||
module "development" { | ||
source = "../../../modules/environment" | ||
environment = "development" | ||
|
||
# Project configuration | ||
project = "{{ .Config.Infrastructure.AWS.EKS.ClusterName }}" | ||
region = "{{ .Config.Infrastructure.AWS.Region }}" | ||
allowed_account_ids = ["{{ .Config.Infrastructure.AWS.AccountId }}"] | ||
|
||
# ECR configuration | ||
ecr_repositories = ["{{ .Config.Infrastructure.AWS.EKS.ClusterName }}"] | ||
|
||
# EKS configuration | ||
eks_worker_instance_type = "t2.small" | ||
eks_worker_asg_max_size = 2 | ||
|
||
# EKS-Optimized AMI for your region: https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html | ||
# https://us-east-1.console.aws.amazon.com/systems-manager/parameters/%252Faws%252Fservice%252Feks%252Foptimized-ami%252F1.14%252Famazon-linux-2%252Frecommended%252Fimage_id/description?region=us-east-1 | ||
eks_worker_ami = "{{ .Config.Infrastructure.AWS.EKS.WorkerAMI }}" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
templates/kubernetes/terraform/environments/production/kubernetes/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
terraform { | ||
backend "s3" { | ||
bucket = "project-{{ .Config.Name }}-terraform-state" | ||
key = "infrastructure/terraform/environments/production/main" | ||
encrypt = true | ||
region = "{{ .Config.Infrastructure.AWS.Region }}" | ||
dynamodb_table = "{{ .Config.Name }}-terraform-state-locks" | ||
} | ||
} | ||
|
||
# Provision kubernetes resources required to run services/applications | ||
module "kubernetes" { | ||
source = "../../../modules/kubernetes" | ||
|
||
environment = "production" | ||
region = "{{ .Config.Infrastructure.AWS.Region }}" | ||
|
||
# Authenticate with the EKS cluster via the cluster id | ||
cluster_name = "{{ .Config.Infrastructure.AWS.EKS.ClusterName }}" | ||
|
||
# Assume-role policy used by monitoring fluentd daemonset | ||
assume_role_policy = data.aws_iam_policy_document.assumerole_root_policy.json | ||
} | ||
|
||
# Data sources for EKS IAM | ||
data "aws_caller_identity" "current" {} | ||
|
||
data "aws_iam_policy_document" "assumerole_root_policy" { | ||
statement { | ||
actions = ["sts:AssumeRole"] | ||
|
||
principals { | ||
type = "AWS" | ||
identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
templates/kubernetes/terraform/environments/staging/kubernetes/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
terraform { | ||
backend "s3" { | ||
bucket = "project-{{ .Config.Name }}-terraform-state" | ||
key = "infrastructure/terraform/environments/staging/kubernetes" | ||
encrypt = true | ||
region = "{{ .Config.Infrastructure.AWS.Region }}" | ||
dynamodb_table = "{{ .Config.Name }}-terraform-state-locks" | ||
} | ||
} | ||
|
||
# Provision kubernetes resources required to run services/applications | ||
module "kubernetes" { | ||
source = "../../../modules/kubernetes" | ||
|
||
environment = "staging" | ||
region = "{{ .Config.Infrastructure.AWS.Region }}" | ||
|
||
# Authenticate with the EKS cluster via the cluster id | ||
cluster_name = "{{ .Config.Infrastructure.AWS.EKS.ClusterName }}" | ||
|
||
# Assume-role policy used by monitoring fluentd daemonset | ||
assume_role_policy = data.aws_iam_policy_document.assumerole_root_policy.json | ||
} | ||
|
||
# Data sources for EKS IAM | ||
data "aws_caller_identity" "current" {} | ||
|
||
data "aws_iam_policy_document" "assumerole_root_policy" { | ||
statement { | ||
actions = ["sts:AssumeRole"] | ||
|
||
principals { | ||
type = "AWS" | ||
identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters