Skip to content

Commit

Permalink
Using azs from az-subnet map (#34)
Browse files Browse the repository at this point in the history
* Using azs from az-subnet map

* az_subnets change
  • Loading branch information
rishi-anand authored May 7, 2021
1 parent ed78ec4 commit a5b9787
Show file tree
Hide file tree
Showing 5 changed files with 250 additions and 71 deletions.
13 changes: 11 additions & 2 deletions docs/resources/cloudaccount_aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@ resource "spectrocloud_cloudaccount_aws" "aws-1" {
aws_secret_key = var.aws_secret_key
}
```
```terraform
resource "spectrocloud_cloudaccount_aws" "aws-2" {
name = "aws-1"
type = "sts"
arn = var.arn
external_id = var.external_id
}
```


## Schema

### Required

- **aws_access_key** (String)
- **aws_secret_key** (String, Sensitive)
- **aws_access_key** (String) & **aws_secret_key** (String, Sensitive) if `type` is `secret`
- **arn** (String) & **external_id** (String, Sensitive) if `type` is `sts`
- **name** (String)

### Optional
Expand Down
203 changes: 203 additions & 0 deletions docs/resources/cluster_eks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
---
page_title: "spectrocloud_cluster_eks Resource - terraform-provider-spectrocloud"
subcategory: ""
description: |-
---

# Resource `spectrocloud_cluster_eks`



## Example Usage

```terraform
data "spectrocloud_cloudaccount_aws" "account" {
# id = <uid>
name = var.cluster_cloud_account_name
}
data "spectrocloud_cluster_profile" "profile" {
# id = <uid>
name = var.cluster_cluster_profile_name
}
resource "spectrocloud_cluster_eks" "cluster" {
name = var.cluster_name
cluster_profile_id = data.spectrocloud_cluster_profile.profile.id
cloud_account_id = data.spectrocloud_cloudaccount_aws.account.id
cloud_config {
ssh_key_name = "default"
region = "us-west-2"
}
# To override or specify values for a cluster:
# pack {
# name = "spectro-byo-manifest"
# tag = "1.0.x"
# values = <<-EOT
# manifests:
# byo-manifest:
# contents: |
# # Add manifests here
# apiVersion: v1
# kind: Namespace
# metadata:
# labels:
# app: wordpress
# app2: wordpress2
# name: wordpress
# EOT
# }
machine_pool {
control_plane = true
name = "master-pool"
count = 1
instance_type = "t3.large"
disk_size_gb = 62
}
machine_pool {
name = "worker-basic"
count = 1
instance_type = "t3.large"
}
}
```

```terraform
data "spectrocloud_cloudaccount_aws" "account" {
# id = <uid>
name = var.cluster_cloud_account_name
}
data "spectrocloud_cluster_profile" "profile" {
# id = <uid>
name = var.cluster_cluster_profile_name
}
resource "spectrocloud_cluster_eks" "cluster" {
name = var.cluster_name
cluster_profile_id = data.spectrocloud_cluster_profile.profile.id
cloud_account_id = data.spectrocloud_cloudaccount_aws.account.id
cloud_config {
ssh_key_name = "default"
region = "us-west-2"
vpc_id = "vpc-123"
}
# To override or specify values for a cluster:
# pack {
# name = "spectro-byo-manifest"
# tag = "1.0.x"
# values = <<-EOT
# manifests:
# byo-manifest:
# contents: |
# # Add manifests here
# apiVersion: v1
# kind: Namespace
# metadata:
# labels:
# app: wordpress
# app2: wordpress2
# name: wordpress
# EOT
# }
machine_pool {
control_plane = true
name = "master-pool"
count = 1
instance_type = "t3.large"
disk_size_gb = 62
az_subnets = {
"us-west-2a" = "subnet-0d4978ddbff16c868"
}
}
machine_pool {
name = "worker-basic"
count = 1
instance_type = "t3.large"
az_subnets = {
"us-west-2a" = "subnet-0d4978ddbff16c868"
}
}
}
```

## Schema

### Required

- **cloud_account_id** (String)
- **cloud_config** (Block List, Min: 1, Max: 1) (see [below for nested schema](#nestedblock--cloud_config))
- **cluster_profile_id** (String)
- **machine_pool** (Block Set, Min: 1) (see [below for nested schema](#nestedblock--machine_pool))
- **name** (String)

### Optional

- **id** (String) The ID of this resource.
- **pack** (Block Set) (see [below for nested schema](#nestedblock--pack))
- **timeouts** (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
### Read-only

- **cloud_config_id** (String)
- **kubeconfig** (String)

<a id="nestedblock--cloud_config"></a>
### Nested Schema for `cloud_config`

Required:

- **region** (String)
- **ssh_key_name** (String)


<a id="nestedblock--machine_pool"></a>
### Nested Schema for `machine_pool`

Required:

- **azs** (Set of String)
- **count** (Number)
- **instance_type** (String)
- **name** (String)

Optional:

- **control_plane** (Boolean)
- **disk_size_gb** (Number)


<a id="nestedblock--pack"></a>
### Nested Schema for `pack`

Required:

- **name** (String)
- **tag** (String)
- **values** (String)


<a id="nestedblock--timeouts"></a>
### Nested Schema for `timeouts`

Optional:

- **create** (String)
- **delete** (String)
- **update** (String)


14 changes: 5 additions & 9 deletions examples/e2e/eks/resource_cluster.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ resource "spectrocloud_cluster_eks" "cluster" {
ssh_key_name = var.aws_ssh_key_name
region = var.aws_region
vpc_id = "vpc-0e03ff84a894d40a2"
endpoint_access = "public"

}

# To override or specify values for a cluster:
Expand Down Expand Up @@ -38,15 +36,13 @@ resource "spectrocloud_cluster_eks" "cluster" {
count = 1
instance_type = "t3.large"
disk_size_gb = 62
azs = var.aws_region_az
subnets = var.master_azs_subnets_map
az_subnets = var.master_azs_subnets_map
}

machine_pool {
name = "worker-basic"
count = 1
instance_type = "t3.large"
azs = var.aws_region_az
subnets = var.worker_azs_subnets_map
name = "worker-basic"
count = 1
instance_type = "t3.large"
az_subnets = var.worker_azs_subnets_map
}
}
18 changes: 8 additions & 10 deletions examples/e2e/eks/terraform.template.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@ sc_username = "{enter Spectro Cloud username}" #e.g: [email protected]
sc_password = "{enter Spectro Cloud password}" #e.g: supereSecure1!
sc_project_name = "{enter Spectro Cloud project Name}" #e.g: Default

# Existing SSH Key in AWS
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html
aws_ssh_key_name = "{enter AWS SSH key name}" #e.g: default

# Enter the AWS Region and AZ for cluster resources
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions
aws_region = "{enter AWS Region}" #e.g: us-west-2
aws_region_az = ["{enter AWS Availability Zone A}", "{enter AWS Availability Zone B}"] #e.g: ["us-west-2a", "us-west-2b"]


# AWS Cloud Account credentials
# Ensure minimum AWS account permissions:
Expand All @@ -29,7 +20,14 @@ aws_secret_key = "{enter AWS secret key}"
arn = "{enter AWS Arn}"
external_id = "{enter AWS External Id}"

aws_region_az = ["us-west-2a", "us-west-2b"] #e.g: us-west-2a

# Existing SSH Key in AWS
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html
aws_ssh_key_name = "{enter AWS SSH key name}" #e.g: default

# Enter the AWS Region and AZ for cluster resources
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions
aws_region = "{enter AWS Region}" #e.g: us-west-2

master_azs_subnets_map = {
"{enter AWS Availability Zone A}" = "{enter Subnet For Availability Zone A}",
Expand Down
Loading

0 comments on commit a5b9787

Please sign in to comment.