Skip to content

Commit d6725e2

Browse files
chore: Update Terraform versions and required providers in modules
1 parent 5b57098 commit d6725e2

File tree

89 files changed

+3323
-569
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+3323
-569
lines changed

.github/workflows/tf-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Render terraform docs inside modules
2828
uses: terraform-docs/[email protected]
2929
with:
30-
working-dir: modules/amplify-app,modules/bastion,modules/mongodb,modules/rds,modules/rds-aurora,modules/vpc,modules/vpc-endpoints,live/terraform-backend,live/core-networking,live/common-infra
30+
working-dir: modules/*,live/*
3131
output-file: docs/MODULE.md
3232
output-method: replace
3333
git-push: "true"

README.md

Lines changed: 41 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ Welcome to the Terraform AWS Starter Kit! This comprehensive and robust starter
1212

1313
The Terraform AWS Starter Kit solves the most challenging aspect of AWS infrastructure building by providing a powerful solution for our clients. Our goal is to simplify the process of setting up a reliable and scalable AWS environment, allowing you to focus on developing and deploying your applications swiftly and confidently.
1414

15-
<picture>
16-
<source media="(prefers-color-scheme: dark)" alt="" align="right" width="400px" srcset="./tools/dac/live_prod_infrastructure.png"/>
17-
<img alt="" align="right" width="400px" src="./tools/dac/live_prod_infrastructure.png"/>
18-
</picture>
19-
2015
## Key Features
2116

2217
### Secure State Management 🔒
@@ -33,7 +28,11 @@ The starter kit implements security groups for the bastion host and database ins
3328

3429
### Database Provisioning 🗃️
3530

36-
We have included configurations to provision an RDS PostgreSQL instance and other database resources. This allows you to easily set up and manage your database infrastructure in a consistent and reproducible manner.
31+
We have included configurations to provision an RDS PostgreSQL instance, RDS Aurora cluster, MSK cluster, MongoDB Atlas cluster, and more. These configurations enable you to set up and manage your databases with ease, ensuring optimal performance and reliability for your applications.
32+
33+
### Kubernetes Cluster Provisioning 🚢
34+
35+
Our starter kit includes configurations to provision an Amazon Elastic Kubernetes Service (EKS) cluster. This enables you to deploy and manage containerized applications using Kubernetes, leveraging the scalability and flexibility of AWS for your workloads.
3736

3837
### Secrets Management 🔑
3938

@@ -60,45 +59,55 @@ We welcome contributions and feedback to improve this starter kit further, makin
6059

6160
## Quick Start
6261

63-
Check the [Live Infrastructure](#live-infrastructure) section for more information about existing infrastructure modules and how to use them.
64-
65-
Once you have chosen the infrastructure module you want to use, move to the module directory and follow the instructions in the README file.
62+
To get started, explore the available modules and scripts, and follow the instructions provided in their respective README files. For a more hands-on introduction, you can start with the examples provided in the [**Live Infrastructure**](#live-infrastructure) and [**Infra Tools and Scripts**](#infra-tools-and-scripts) sections.
6663

6764
## Live Infrastructure
6865

69-
The `live` directory houses our live infrastructure components. This is where you'll find our Terraform variables, backend configuration, and Terraform root modules.
70-
71-
It is recommended to create a separate directory for each domain that you want to manage with Terraform. For example, you could have a `core-networking` directory for managing your VPC, subnets, and security groups, and a `common-infra` directory for managing your RDS instances, S3 buckets, and other shared resources.
66+
The `live` directory houses our active infrastructure configurations. These configurations are organized by domain, allowing you to manage different parts of your infrastructure separately.
7267

73-
| Module | Description |
74-
| :-------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------- |
75-
| [Terraform Backend Configuration](./live/terraform-backend/README.md) | Terraform module for setting up the S3 backend. |
76-
| [AWS IAM Management](./live/aws-iam-management/README.md) | Terraform module for managing IAM roles and policies. |
77-
| [Core Networking](./live/core-networking/README.md) | Terraform module for managing core networking components such as VPC, subnets, and security groups. |
78-
| [Common Infrastructure](./live/common-infra/README.md) | Terraform module for managing common infrastructure components such as RDS instances, S3 buckets, and IAM roles. |
68+
| Module | Description |
69+
| :-------------------------------------------------------------------- | :-------------------------------------------------------------------------------------- |
70+
| [Terraform Backend Configuration](./live/terraform-backend/README.md) | Set up the Terraform backend with an S3 bucket and DynamoDB table for state management. |
71+
| [AWS IAM Management](./live/iam-management/README.md) | Manage IAM roles and policies. |
72+
| [Core Networking](./live/core-networking/README.md) | Manage core networking components such as VPCs, subnets, and security groups. |
73+
| [Services Platform](./live/services-platform/README.md) | Manage services platform components, including EKS clusters. |
7974

8075
## Terraform Modules
8176

82-
We have created custom Terraform modules to bootstrap our infrastructure, which are located in the `modules` directory.
77+
Our custom Terraform modules are located in the `modules` directory. These modules are reusable and help you bootstrap various parts of your infrastructure.
8378

84-
| Module | Description |
85-
| :--------------------------------------------------- | :------------------------------------------------------------------------------- |
86-
| [Amplify App](./modules/amplify-app/README.md) | Terraform module for bootstrapping an Amplify app. |
87-
| [Bastion](./modules/bastion/README.md) | Terraform module for bootstrapping a bastion host. |
88-
| [AWS IAM Role](./modules/iam-role/README.md) | Terraform module for bootstrapping an AWS IAM role. |
89-
| [RDS Instance](./modules/rds/README.md) | Terraform module for bootstrapping an RDS Instance. |
90-
| [RDS Aurora Cluster](./modules/rds-aurora/README.md) | Terraform module for bootstrapping an RDS Aurora Cluster. |
91-
| [VPC](./modules/vpc/README.md) | Terraform module for bootstrapping a VPC for use with our shared infrastructure. |
79+
| Module | Description |
80+
| :--------------------------------------------------- | :------------------------------------------------------------ |
81+
| [Amplify App](./modules/amplify-app/README.md) | Bootstrap an Amplify app. |
82+
| [Bastion](./modules/bastion/README.md) | Bootstrap a bastion host. |
83+
| [EKS](./modules/eks/README.md) | Bootstrap an EKS cluster. |
84+
| [AWS IAM Role](./modules/iam-role/README.md) | Bootstrap an AWS IAM role. |
85+
| [MSK Cluster](./modules/msk/README.md) | Bootstrap an MSK cluster. |
86+
| [RDS Instance](./modules/rds/README.md) | Bootstrap an RDS Instance. |
87+
| [RDS Aurora Cluster](./modules/rds-aurora/README.md) | Bootstrap an RDS Aurora Cluster. |
88+
| [VPC](./modules/vpc/README.md) | Bootstrap a VPC for shared infrastructure. |
89+
| [VPC Endpoint](./modules/vpc-endpoint/README.md) | Bootstrap VPC endpoints for S3, DynamoDB, and other services. |
9290

9391
## Apps and Services
9492

95-
In addition to infrastructure provisioning, we have included a few apps and services to help you get started.
93+
In addition to infrastructure provisioning, we have included a few apps and services to help you get started. These are located in the `apps` directory and provide useful examples of how to use the infrastructure we have provisioned.
94+
95+
| Service | Description |
96+
| :-------------------------------------------------------------- | :---------------------------------------------------------------------------------------- |
97+
| [Start and Stop EC2 Instance](./apps/start-stop-ec2-instances/) | A Serverless Framework-based project to start and stop EC2 instances based on a schedule. |
98+
99+
## Infra Tools and Scripts
100+
101+
This section contains additional tools and scripts that complement our Terraform modules, helping you manage specific tasks.
102+
103+
**What tools and scripts are available?**
96104

97-
These apps and services are located in the `apps` directory. In there you can find useful examples of how to use the infrastructure we have provisioned.
105+
- Bastion Host Connection script: Connect to an AWS Bastion host securely.
106+
- Generate `kubeconfig` script: Generate a `kubeconfig` file for an EKS Cluster.
107+
- Tunnel to EKS Cluster script: Create a tunnel to an EKS Cluster for `kubectl` access.
108+
- and more!
98109

99-
| Service | Description |
100-
| :-------------------------------------------------------------- | :------------------------------------------------------------------------------------------------ |
101-
| [Start and Stop EC2 Instance](./apps/start-stop-ec2-instances/) | This is a Serverless Framework based project to start and stop EC2 instances based on a schedule. |
110+
Refer to the [Infra Tools and Scripts README](./scripts/README.md) for more details and usage examples!
102111

103112
## Best practices
104113

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
region = "us-west-2"
2+
bucket = "nan-develop-tfbackend-state"
3+
key = "nan-develop-aws-iam-management.tfstate"
4+
encrypt = "true"
5+
profile = ""

live/aws-iam-management/configs/prod.tfvars renamed to live/aws-iam-management/configs/develop.tfvars

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
region = "us-west-2"
44
name = "aws-iam-management"
55
namespace = "nan"
6-
environment = "prod"
7-
tags = {}
6+
environment = "develop"
7+
tags = {
8+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
region = "us-west-2"
2+
bucket = "nan-sandbox-tfbackend-state"
3+
key = "nan-sandbox-aws-iam-management.tfstate"
4+
encrypt = "true"
5+
profile = ""

live/aws-iam-management/configs/staging.tfvars renamed to live/aws-iam-management/configs/sandbox.tfvars

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
region = "us-west-2"
44
name = "aws-iam-management"
55
namespace = "nan"
6-
environment = "staging"
7-
tags = {}
6+
environment = "sandbox"
7+
tags = {
8+
}

live/aws-iam-management/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ provider "aws" {
55
tags = merge(module.label.tags, {
66
ManagedBy = "terraform"
77
Owner = "NaNLABS"
8+
Project = "[Project Name]"
89
Repository = "https://github.com/nanlabs/terraform-aws-starter"
910
RepositoryPath = "live/aws-iam-management"
1011
})
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
region = "us-west-2"
2+
bucket = "nan-develop-tfbackend-state"
3+
key = "nan-develop-common-infra.tfstate"
4+
encrypt = "true"
5+
profile = ""

live/common-infra/configs/prod.tfvars renamed to live/common-infra/configs/develop.tfvars

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
region = "us-west-2"
44
name = "common-infra"
55
namespace = "nan"
6-
environment = "prod"
7-
tags = {}
6+
environment = "develop"
7+
tags = {
8+
}
89

910
# Core Networking settings
1011

11-
core_networking_ssm_parameter_prefix = "/nan-core-networking-prod"
12+
core_networking_ssm_parameter_prefix = "/nan-core-networking-develop"
1213

1314
# RDS Database settings
1415

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
region = "us-west-2"
2+
bucket = "nan-sandbox-tfbackend-state"
3+
key = "nan-sandbox-common-infra.tfstate"
4+
encrypt = "true"
5+
profile = ""

live/common-infra/configs/staging.tfvars renamed to live/common-infra/configs/sandbox.tfvars

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
region = "us-west-2"
44
name = "common-infra"
55
namespace = "nan"
6-
environment = "staging"
7-
tags = {}
6+
environment = "sandbox"
7+
tags = {
8+
}
89

910
# Core Networking settings
1011

11-
core_networking_ssm_parameter_prefix = "/nan-core-networking-staging"
12+
core_networking_ssm_parameter_prefix = "/nan-core-networking-sandbox"
1213

1314
# RDS Database settings
1415

live/core-networking/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
Initialize the working directory with the required providers and modules:
3434

3535
```sh
36-
terraform init -backend-config="./configs/prod-backend.tfvars"
36+
terraform init -backend-config="./configs/sandbox-backend.tfvars"
3737
```
3838

3939
3. **Workspace Management:**
@@ -42,12 +42,12 @@
4242

4343
```sh
4444
# Select an existing workspace
45-
terraform workspace select prod
45+
terraform workspace select sandbox
4646

4747
# Create a new workspace if it doesn't exist
4848
# and select it
49-
terraform workspace new prod
50-
terraform workspace select prod
49+
terraform workspace new sandbox
50+
terraform workspace select sandbox
5151
```
5252
5353
## Deploy

live/core-networking/bastion.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module "bastion" {
1212
vpc_id = module.vpc.vpc_id
1313
private_subnets = module.vpc.private_subnets
1414
instance_type = "t2.micro"
15-
tags = module.label.tags
15+
tags = merge(module.label.tags, { "Name" = "${module.label.id}-bastion" })
1616
}
1717

1818
output "bastion_instance_id" {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
region = "us-west-2"
2+
bucket = "nan-develop-tfbackend-state"
3+
key = "nan-develop-core-networking.tfstate"
4+
encrypt = "true"
5+
profile = ""

live/core-networking/configs/staging.tfvars renamed to live/core-networking/configs/develop.tfvars

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
region = "us-west-2"
44
name = "core-networking"
55
namespace = "nan"
6-
environment = "staging"
6+
environment = "develop"
77
tags = {}
88

9-
# AWS settings
9+
# Resources settings
1010

1111
vpc_cidr_block = "10.0.0.0/16"
1212
enable_bastion = true
13+
14+
cluster_name = "nan-develop-services-platform-cluster"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
region = "us-west-2"
2+
bucket = "nan-sandbox-tfbackend-state"
3+
key = "nan-sandbox-core-networking.tfstate"
4+
encrypt = "true"
5+
profile = ""

live/core-networking/configs/prod.tfvars renamed to live/core-networking/configs/sandbox.tfvars

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
region = "us-west-2"
44
name = "core-networking"
55
namespace = "nan"
6-
environment = "prod"
6+
environment = "sandbox"
77
tags = {}
88

9-
# AWS settings
9+
# Resources settings
1010

1111
vpc_cidr_block = "10.0.0.0/16"
1212
enable_bastion = true
13+
14+
cluster_name = "nan-sandbox-services-platform-cluster"

live/core-networking/docs/MODULE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ No resources.
2727

2828
| Name | Description | Type | Default | Required |
2929
|------|-------------|------|---------|:--------:|
30+
| <a name="input_cluster_name"></a> [cluster\_name](#input\_cluster\_name) | The name of the EKS cluster | `string` | n/a | yes |
3031
| <a name="input_enable_bastion"></a> [enable\_bastion](#input\_enable\_bastion) | Enable bastion host | `bool` | `false` | no |
3132
| <a name="input_environment"></a> [environment](#input\_environment) | Environment, e.g. 'prod', 'staging', 'dev', 'pre-prod', 'UAT' | `string` | `"development"` | no |
3233
| <a name="input_name"></a> [name](#input\_name) | Name to use for servers, tags, etc | `string` | `"name"` | no |

live/core-networking/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ provider "aws" {
55
tags = merge(module.label.tags, {
66
ManagedBy = "terraform"
77
Owner = "NaNLABS"
8+
Project = "[Project Name]"
89
Repository = "https://github.com/nanlabs/terraform-aws-starter"
910
RepositoryPath = "live/core-networking"
1011
})

live/core-networking/vpc-endpoints.tf

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,7 @@ module "vpc_endpoints" {
1010
route_table_ids = module.vpc.public_route_table_ids
1111
policy = null
1212
tags = { Name = "${module.label.id}-s3-vpc-endpoint" }
13-
}
14-
# ec2 = {
15-
# service = "ec2"
16-
# service_type = "Interface"
17-
# security_group_ids = [module.vpc.default_security_group_id]
18-
# private_dns_enabled = true
19-
# subnet_ids = module.vpc.private_subnets
20-
# policy = null
21-
# tags = { Name = "${module.label.id}-ec2-vpc-endpoint" }
22-
# },
23-
# ssm = {
24-
# service = "ssm"
25-
# service_type = "Interface"
26-
# security_group_ids = [module.vpc.default_security_group_id]
27-
# private_dns_enabled = true
28-
# subnet_ids = module.vpc.private_subnets
29-
# policy = null
30-
# tags = { Name = "${module.label.id}-ssm-vpc-endpoint" }
31-
# },
32-
# ec2messages = {
33-
# service = "ec2messages"
34-
# service_type = "Interface"
35-
# security_group_ids = [module.vpc.default_security_group_id]
36-
# private_dns_enabled = true
37-
# subnet_ids = module.vpc.private_subnets
38-
# policy = null
39-
# tags = { Name = "${module.label.id}-ec2messages-vpc-endpoint" }
40-
# },
41-
# ssmmessages = {
42-
# service = "ssmmessages"
43-
# service_type = "Interface"
44-
# security_group_ids = [module.vpc.default_security_group_id]
45-
# private_dns_enabled = true
46-
# subnet_ids = module.vpc.private_subnets
47-
# policy = null
48-
# tags = { Name = "${module.label.id}-ssmmessages-vpc-endpoint" }
49-
# }
13+
},
5014
}
5115

5216
security_group_ids = [module.vpc.default_security_group_id]

live/core-networking/vpc.tf

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,35 @@ variable "vpc_cidr_block" {
44
default = "10.0.0.0/16"
55
}
66

7+
variable "cluster_name" {
8+
description = "The name of the EKS cluster"
9+
type = string
10+
}
11+
12+
locals {
13+
# The usage of the specific kubernetes.io/cluster/* resource tags below are required
14+
# for EKS and Kubernetes to discover and manage networking resources
15+
# https://aws.amazon.com/premiumsupport/knowledge-center/eks-vpc-subnet-discovery/
16+
tags = merge(var.tags, { "kubernetes.io/cluster/${var.cluster_name}" = "shared" })
17+
18+
# required tags to make ALB ingress work https://docs.aws.amazon.com/eks/latest/userguide/alb-ingress.html
19+
public_subnets_additional_tags = {
20+
"kubernetes.io/role/elb" : 1
21+
}
22+
private_subnets_additional_tags = {
23+
"kubernetes.io/role/internal-elb" : 1
24+
}
25+
}
26+
727
module "vpc" {
8-
source = "../../modules/vpc"
9-
name = module.label.id
10-
vpc_cidr_block = var.vpc_cidr_block
11-
tags = module.label.tags
12-
enable_nat_gateway = true
13-
single_nat_gateway = true
28+
source = "../../modules/vpc"
29+
name = module.label.id
30+
vpc_cidr_block = var.vpc_cidr_block
31+
enable_nat_gateway = true
32+
single_nat_gateway = true
33+
tags = local.tags
34+
public_subnet_tags = local.public_subnets_additional_tags
35+
private_subnet_tags = local.private_subnets_additional_tags
1436
}
1537

1638
output "ssm_parameter_vpc_id" {

0 commit comments

Comments
 (0)