Skip to content

Commit aa87428

Browse files
Merge pull request #39 from MaterializeInc/remove-provider-config
Remove providers definition from root module
2 parents 70d3b59 + 4566434 commit aa87428

File tree

9 files changed

+143
-56
lines changed

9 files changed

+143
-56
lines changed

README.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,56 @@ The module has been tested with:
99
- PostgreSQL 15
1010
- Materialize Helm Operator Terraform Module v0.1.1
1111

12+
## Providers Configuration
13+
14+
The module requires the following providers to be configured:
15+
16+
```hcl
17+
provider "aws" {
18+
region = "us-east-1"
19+
# Other AWS provider configuration as needed
20+
}
21+
22+
# Required for EKS authentication
23+
provider "kubernetes" {
24+
host = module.materialize_infrastructure.eks_cluster_endpoint
25+
cluster_ca_certificate = base64decode(module.materialize_infrastructure.cluster_certificate_authority_data)
26+
27+
exec {
28+
api_version = "client.authentication.k8s.io/v1beta1"
29+
args = ["eks", "get-token", "--cluster-name", module.materialize_infrastructure.eks_cluster_name]
30+
command = "aws"
31+
}
32+
}
33+
34+
# Required for Materialize Operator installation
35+
provider "helm" {
36+
kubernetes {
37+
host = module.materialize_infrastructure.eks_cluster_endpoint
38+
cluster_ca_certificate = base64decode(module.materialize_infrastructure.cluster_certificate_authority_data)
39+
40+
exec {
41+
api_version = "client.authentication.k8s.io/v1beta1"
42+
args = ["eks", "get-token", "--cluster-name", module.materialize_infrastructure.eks_cluster_name]
43+
command = "aws"
44+
}
45+
}
46+
}
47+
48+
module "materialize_infrastructure" {
49+
source = "git::https://github.com/MaterializeInc/terraform-aws-materialize.git"
50+
# Other required variables
51+
}
52+
```
53+
54+
> **Note:** The Kubernetes and Helm providers are configured to use the AWS CLI for authentication with the EKS cluster. This requires that you have the AWS CLI installed and configured with access to the AWS account where the EKS cluster is deployed.
55+
56+
You can also set the `AWS_PROFILE` environment variable to the name of the profile you want to use for authentication with the EKS cluster:
57+
58+
```bash
59+
export AWS_PROFILE=your-profile-name
60+
```
61+
1262
## Requirements
1363

1464
| Name | Version |
@@ -54,7 +104,7 @@ The module has been tested with:
54104
|------|-------------|------|---------|:--------:|
55105
| <a name="input_availability_zones"></a> [availability\_zones](#input\_availability\_zones) | List of availability zones | `list(string)` | <pre>[<br/> "us-east-1a",<br/> "us-east-1b",<br/> "us-east-1c"<br/>]</pre> | no |
56106
| <a name="input_bucket_force_destroy"></a> [bucket\_force\_destroy](#input\_bucket\_force\_destroy) | Enable force destroy for the S3 bucket | `bool` | `true` | no |
57-
| <a name="input_bucket_lifecycle_rules"></a> [bucket\_lifecycle\_rules](#input\_bucket\_lifecycle\_rules) | List of lifecycle rules for the S3 bucket | <pre>list(object({<br/> id = string<br/> enabled = bool<br/> prefix = string<br/> transition_days = number<br/> transition_storage_class = string<br/> expiration_days = number<br/> noncurrent_version_expiration_days = number<br/> }))</pre> | <pre>[<br/> {<br/> "enabled": true,<br/> "expiration_days": 365,<br/> "id": "cleanup",<br/> "noncurrent_version_expiration_days": 90,<br/> "prefix": "",<br/> "transition_days": 90,<br/> "transition_storage_class": "STANDARD_IA"<br/> }<br/>]</pre> | no |
107+
| <a name="input_bucket_lifecycle_rules"></a> [bucket\_lifecycle\_rules](#input\_bucket\_lifecycle\_rules) | List of lifecycle rules for the S3 bucket | <pre>list(object({<br/> id = string<br/> enabled = bool<br/> prefix = string<br/> transition_days = number<br/> transition_storage_class = string<br/> noncurrent_version_expiration_days = number<br/> }))</pre> | <pre>[<br/> {<br/> "enabled": true,<br/> "id": "cleanup",<br/> "noncurrent_version_expiration_days": 90,<br/> "prefix": "",<br/> "transition_days": 90,<br/> "transition_storage_class": "STANDARD_IA"<br/> }<br/>]</pre> | no |
58108
| <a name="input_cluster_enabled_log_types"></a> [cluster\_enabled\_log\_types](#input\_cluster\_enabled\_log\_types) | List of desired control plane logging to enable | `list(string)` | <pre>[<br/> "api",<br/> "audit",<br/> "authenticator",<br/> "controllerManager",<br/> "scheduler"<br/>]</pre> | no |
59109
| <a name="input_cluster_version"></a> [cluster\_version](#input\_cluster\_version) | Kubernetes version for the EKS cluster | `string` | `"1.32"` | no |
60110
| <a name="input_create_vpc"></a> [create\_vpc](#input\_create\_vpc) | Controls if VPC should be created (it affects almost all resources) | `bool` | `true` | no |
@@ -103,6 +153,7 @@ The module has been tested with:
103153

104154
| Name | Description |
105155
|------|-------------|
156+
| <a name="output_cluster_certificate_authority_data"></a> [cluster\_certificate\_authority\_data](#output\_cluster\_certificate\_authority\_data) | Base64 encoded certificate data required to communicate with the cluster |
106157
| <a name="output_database_endpoint"></a> [database\_endpoint](#output\_database\_endpoint) | RDS instance endpoint |
107158
| <a name="output_eks_cluster_endpoint"></a> [eks\_cluster\_endpoint](#output\_eks\_cluster\_endpoint) | EKS cluster endpoint |
108159
| <a name="output_eks_cluster_name"></a> [eks\_cluster\_name](#output\_eks\_cluster\_name) | EKS cluster name |

docs/header.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,53 @@ Terraform module for deploying Materialize on AWS Cloud Platform with all requir
77
The module has been tested with:
88
- PostgreSQL 15
99
- Materialize Helm Operator Terraform Module v0.1.1
10+
11+
## Providers Configuration
12+
13+
The module requires the following providers to be configured:
14+
15+
```hcl
16+
provider "aws" {
17+
region = "us-east-1"
18+
# Other AWS provider configuration as needed
19+
}
20+
21+
# Required for EKS authentication
22+
provider "kubernetes" {
23+
host = module.materialize_infrastructure.eks_cluster_endpoint
24+
cluster_ca_certificate = base64decode(module.materialize_infrastructure.cluster_certificate_authority_data)
25+
26+
exec {
27+
api_version = "client.authentication.k8s.io/v1beta1"
28+
args = ["eks", "get-token", "--cluster-name", module.materialize_infrastructure.eks_cluster_name]
29+
command = "aws"
30+
}
31+
}
32+
33+
# Required for Materialize Operator installation
34+
provider "helm" {
35+
kubernetes {
36+
host = module.materialize_infrastructure.eks_cluster_endpoint
37+
cluster_ca_certificate = base64decode(module.materialize_infrastructure.cluster_certificate_authority_data)
38+
39+
exec {
40+
api_version = "client.authentication.k8s.io/v1beta1"
41+
args = ["eks", "get-token", "--cluster-name", module.materialize_infrastructure.eks_cluster_name]
42+
command = "aws"
43+
}
44+
}
45+
}
46+
47+
module "materialize_infrastructure" {
48+
source = "git::https://github.com/MaterializeInc/terraform-aws-materialize.git"
49+
# Other required variables
50+
}
51+
```
52+
53+
> **Note:** The Kubernetes and Helm providers are configured to use the AWS CLI for authentication with the EKS cluster. This requires that you have the AWS CLI installed and configured with access to the AWS account where the EKS cluster is deployed.
54+
55+
You can also set the `AWS_PROFILE` environment variable to the name of the profile you want to use for authentication with the EKS cluster:
56+
57+
```bash
58+
export AWS_PROFILE=your-profile-name
59+
```

examples/simple/main.tf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,41 @@ provider "aws" {
22
region = "us-east-1"
33
}
44

5+
provider "kubernetes" {
6+
host = module.materialize_infrastructure.eks_cluster_endpoint
7+
cluster_ca_certificate = base64decode(module.materialize_infrastructure.cluster_certificate_authority_data)
8+
9+
exec {
10+
api_version = "client.authentication.k8s.io/v1beta1"
11+
command = "aws"
12+
args = ["eks", "get-token", "--cluster-name", module.materialize_infrastructure.eks_cluster_name]
13+
}
14+
}
15+
16+
provider "helm" {
17+
kubernetes {
18+
host = module.materialize_infrastructure.eks_cluster_endpoint
19+
cluster_ca_certificate = base64decode(module.materialize_infrastructure.cluster_certificate_authority_data)
20+
21+
exec {
22+
api_version = "client.authentication.k8s.io/v1beta1"
23+
command = "aws"
24+
args = ["eks", "get-token", "--cluster-name", module.materialize_infrastructure.eks_cluster_name]
25+
}
26+
}
27+
}
28+
529
module "materialize_infrastructure" {
630
# To pull this from GitHub, use the following:
731
# source = "git::https://github.com/MaterializeInc/terraform-aws-materialize.git"
832
source = "../../"
933

34+
providers = {
35+
aws = aws
36+
kubernetes = kubernetes
37+
helm = helm
38+
}
39+
1040
# The namespace and environment variables are used to construct the names of the resources
1141
# e.g. ${namespace}-${environment}-storage, ${namespace}-${environment}-db etc.
1242
namespace = var.namespace
@@ -140,3 +170,9 @@ output "materialize_s3_role_arn" {
140170
description = "The ARN of the IAM role for Materialize"
141171
value = module.materialize_infrastructure.materialize_s3_role_arn
142172
}
173+
174+
output "cluster_certificate_authority_data" {
175+
description = "The CA certificate for the EKS cluster"
176+
value = module.materialize_infrastructure.cluster_certificate_authority_data
177+
sensitive = true
178+
}

modules/storage/main.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ resource "aws_s3_bucket_lifecycle_configuration" "materialize_storage" {
4949
storage_class = rule.value.transition_storage_class
5050
}
5151

52-
expiration {
53-
days = rule.value.expiration_days
54-
}
55-
5652
noncurrent_version_expiration {
5753
noncurrent_days = rule.value.noncurrent_version_expiration_days
5854
}

modules/storage/variables.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ variable "bucket_lifecycle_rules" {
3434
prefix = string
3535
transition_days = number
3636
transition_storage_class = string
37-
expiration_days = number
3837
noncurrent_version_expiration_days = number
3938
}))
4039
}

outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ output "eks_cluster_name" {
1313
value = module.eks.cluster_name
1414
}
1515

16+
output "cluster_certificate_authority_data" {
17+
description = "Base64 encoded certificate data required to communicate with the cluster"
18+
value = module.eks.cluster_certificate_authority_data
19+
}
20+
1621
output "database_endpoint" {
1722
description = "RDS instance endpoint"
1823
value = module.database.db_instance_endpoint

providers.tf

Lines changed: 0 additions & 23 deletions
This file was deleted.

terraform.tfvars.example

Lines changed: 0 additions & 25 deletions
This file was deleted.

variables.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ variable "bucket_lifecycle_rules" {
218218
prefix = string
219219
transition_days = number
220220
transition_storage_class = string
221-
expiration_days = number
222221
noncurrent_version_expiration_days = number
223222
}))
224223
default = [{
@@ -227,7 +226,6 @@ variable "bucket_lifecycle_rules" {
227226
prefix = ""
228227
transition_days = 90
229228
transition_storage_class = "STANDARD_IA"
230-
expiration_days = 365
231229
noncurrent_version_expiration_days = 90
232230
}]
233231
}

0 commit comments

Comments
 (0)