mirror of
https://github.com/ysoftdevs/terraform-aws-eks.git
synced 2026-03-12 21:35:15 +01:00
refactor: Refactoring to match the rest of terraform-aws-modules (#1583)
This commit is contained in:
60
examples/_bootstrap/README.md
Normal file
60
examples/_bootstrap/README.md
Normal file
@@ -0,0 +1,60 @@
|
||||
# Various bootstrap resources required for other EKS examples
|
||||
|
||||
Configuration in this directory creates some resources required in other EKS examples (such as VPC).
|
||||
|
||||
The resources created here are free (no NAT gateways here) and they can reside in test AWS account.
|
||||
|
||||
## Usage
|
||||
|
||||
To run this example you need to execute:
|
||||
|
||||
```bash
|
||||
$ terraform init
|
||||
$ terraform plan
|
||||
$ terraform apply
|
||||
```
|
||||
|
||||
Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
|
||||
|
||||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
|
||||
## Requirements
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
|
||||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.22.0 |
|
||||
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 1.11 |
|
||||
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 2.1 |
|
||||
|
||||
## Providers
|
||||
|
||||
| Name | Version |
|
||||
|------|---------|
|
||||
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.22.0 |
|
||||
| <a name="provider_random"></a> [random](#provider\_random) | >= 2.1 |
|
||||
|
||||
## Modules
|
||||
|
||||
| Name | Source | Version |
|
||||
|------|--------|---------|
|
||||
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 3.0 |
|
||||
|
||||
## Resources
|
||||
|
||||
| Name | Type |
|
||||
|------|------|
|
||||
| [random_string.suffix](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
|
||||
| [aws_availability_zones.available](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/availability_zones) | data source |
|
||||
|
||||
## Inputs
|
||||
|
||||
No inputs.
|
||||
|
||||
## Outputs
|
||||
|
||||
| Name | Description |
|
||||
|------|-------------|
|
||||
| <a name="output_cluster_name"></a> [cluster\_name](#output\_cluster\_name) | Name of EKS Cluster used in tags for subnets |
|
||||
| <a name="output_region"></a> [region](#output\_region) | AWS region |
|
||||
| <a name="output_vpc"></a> [vpc](#output\_vpc) | Complete output of VPC module |
|
||||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
|
||||
50
examples/_bootstrap/main.tf
Normal file
50
examples/_bootstrap/main.tf
Normal file
@@ -0,0 +1,50 @@
|
||||
provider "aws" {
|
||||
region = local.region
|
||||
}
|
||||
|
||||
locals {
|
||||
region = "eu-west-1"
|
||||
name = "bootstrap-example"
|
||||
vpc_cidr = "10.0.0.0/16"
|
||||
|
||||
cluster_name = "test-eks-${random_string.suffix.result}"
|
||||
}
|
||||
|
||||
data "aws_availability_zones" "available" {}
|
||||
|
||||
resource "random_string" "suffix" {
|
||||
length = 8
|
||||
special = false
|
||||
}
|
||||
|
||||
################################################################################
|
||||
# Supporting Resources
|
||||
################################################################################
|
||||
|
||||
module "vpc" {
|
||||
source = "terraform-aws-modules/vpc/aws"
|
||||
version = "~> 3.0"
|
||||
|
||||
name = local.name
|
||||
cidr = "10.0.0.0/16"
|
||||
|
||||
azs = data.aws_availability_zones.available.names
|
||||
public_subnets = [for k, v in data.aws_availability_zones.available.names : cidrsubnet(local.vpc_cidr, 8, k)]
|
||||
private_subnets = [for k, v in data.aws_availability_zones.available.names : cidrsubnet(local.vpc_cidr, 8, k + 10)]
|
||||
|
||||
# NAT Gateway is disabled in the examples primarily to save costs and be able to recreate VPC faster.
|
||||
enable_nat_gateway = false
|
||||
single_nat_gateway = false
|
||||
|
||||
enable_dns_hostnames = true
|
||||
|
||||
public_subnet_tags = {
|
||||
"kubernetes.io/cluster/${local.cluster_name}" = "shared"
|
||||
"kubernetes.io/role/elb" = "1"
|
||||
}
|
||||
|
||||
private_subnet_tags = {
|
||||
"kubernetes.io/cluster/${local.cluster_name}" = "shared"
|
||||
"kubernetes.io/role/internal-elb" = "1"
|
||||
}
|
||||
}
|
||||
14
examples/_bootstrap/outputs.tf
Normal file
14
examples/_bootstrap/outputs.tf
Normal file
@@ -0,0 +1,14 @@
|
||||
output "region" {
|
||||
description = "AWS region"
|
||||
value = local.region
|
||||
}
|
||||
|
||||
output "cluster_name" {
|
||||
description = "Name of EKS Cluster used in tags for subnets"
|
||||
value = local.cluster_name
|
||||
}
|
||||
|
||||
output "vpc" {
|
||||
description = "Complete output of VPC module"
|
||||
value = module.vpc
|
||||
}
|
||||
0
examples/_bootstrap/variables.tf
Normal file
0
examples/_bootstrap/variables.tf
Normal file
9
examples/_bootstrap/versions.tf
Normal file
9
examples/_bootstrap/versions.tf
Normal file
@@ -0,0 +1,9 @@
|
||||
terraform {
|
||||
required_version = ">= 0.13.1"
|
||||
|
||||
required_providers {
|
||||
aws = ">= 3.22.0"
|
||||
random = ">= 2.1"
|
||||
kubernetes = ">= 1.11"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user