Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: examples for terraform doc #166

Merged
merged 147 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
488d65e
wip opensearch
leiicamundi Sep 25, 2024
5fda68a
update readme
leiicamundi Sep 25, 2024
7b08427
add missing sg
leiicamundi Sep 26, 2024
2c5112e
add types
leiicamundi Sep 26, 2024
d286aaa
update opensearch gha
leiicamundi Sep 26, 2024
9104908
integrate opensearch in the actions
leiicamundi Sep 26, 2024
a9e1cda
fix tests path
leiicamundi Sep 26, 2024
bb62073
wip go tests
leiicamundi Sep 26, 2024
4644752
fix
leiicamundi Sep 27, 2024
bb057be
fix go mod
leiicamundi Sep 27, 2024
31cc348
wip irsa os
leiicamundi Sep 27, 2024
9e8d5ed
fine tune default options
leiicamundi Sep 27, 2024
bc772f1
fix default large type
leiicamundi Sep 30, 2024
1a1237b
re-enable idempotency checks for other modules than eks
leiicamundi Sep 30, 2024
1725cd4
fix destroy
leiicamundi Oct 2, 2024
5239e44
re-enable idempotency tests
leiicamundi Oct 2, 2024
9df3d7e
tests: implement opensearch-client for irsa
leiicamundi Oct 2, 2024
f4e712e
update opensearch tests
leiicamundi Oct 3, 2024
32b2222
delete each cluster one by one
leiicamundi Oct 3, 2024
abc4dd3
remove password auth in opensearch
leiicamundi Oct 3, 2024
21f84f1
wip tests
leiicamundi Oct 3, 2024
91ad9cd
update tests
leiicamundi Oct 3, 2024
878e436
update tests
leiicamundi Oct 3, 2024
e6c38d7
update
leiicamundi Oct 3, 2024
121c7ad
fix tests
leiicamundi Oct 3, 2024
e5fdfab
update doc
leiicamundi Oct 3, 2024
a2becea
update readme
leiicamundi Oct 3, 2024
45ab793
update gomod
leiicamundi Oct 3, 2024
00daf7c
Merge branch 'main' into feature/opensearch
leiicamundi Oct 3, 2024
2205807
fix outpout
leiicamundi Oct 3, 2024
c04688c
fix destroy
leiicamundi Oct 3, 2024
9ab1092
update outputs
leiicamundi Oct 4, 2024
a20fc66
fix conditional
leiicamundi Oct 4, 2024
ede3087
fix output
leiicamundi Oct 4, 2024
e1feec3
fix default aurora role creation
leiicamundi Oct 4, 2024
0c0fbbf
fix node groups labels
leiicamundi Oct 4, 2024
a373333
update default labels
leiicamundi Oct 4, 2024
628a6eb
revert Idempotency for EKS
leiicamundi Oct 4, 2024
4f80303
rettriger-ci
leiicamundi Oct 4, 2024
ee987b1
fix tests
leiicamundi Oct 4, 2024
803a5a8
fix domain name
leiicamundi Oct 4, 2024
56a8e79
fix tests
leiicamundi Oct 5, 2024
a6d5a81
rebase on main
leiicamundi Oct 5, 2024
2f96dd0
rebase on main
leiicamundi Oct 5, 2024
be944eb
revert idempotency tests on eks
leiicamundi Oct 5, 2024
251204f
fix: ensure kubeclient is near in time of the associated tests
leiicamundi Oct 7, 2024
941cd67
merge: main
leiicamundi Oct 7, 2024
9b22af3
merge: main
leiicamundi Oct 7, 2024
435ab1a
wip instructions from doc
leiicamundi Oct 10, 2024
839d40c
apply suggestions from PR review
leiicamundi Oct 10, 2024
2c690f2
indicates how to retrieve the role arn
leiicamundi Oct 10, 2024
0743538
downscale opensearch instances
leiicamundi Oct 10, 2024
7b2e4ef
Merge branch 'main' into feature/opensearch
leiicamundi Oct 10, 2024
8ff0d87
Merge branch 'feature/opensearch' into feature/opensearch-doc
leiicamundi Oct 10, 2024
c3f0909
update reference doc
leiicamundi Oct 10, 2024
02579aa
fix output and ensure failure
leiicamundi Oct 10, 2024
00f4be3
Merge branch 'feature/opensearch' into feature/opensearch-doc
leiicamundi Oct 10, 2024
1140c96
update list of sa accounts for opensearch
leiicamundi Oct 10, 2024
4974d65
wip create database
leiicamundi Oct 10, 2024
4de3db4
align instances count with number of AZs
leiicamundi Oct 10, 2024
737f3e2
Merge branch 'feature/opensearch' into feature/opensearch-doc
leiicamundi Oct 10, 2024
ce94457
update permissions and creation example
leiicamundi Oct 11, 2024
176443e
Merge branch 'main' into feature/opensearch-doc
leiicamundi Oct 11, 2024
f3efe97
Merge branch 'main' into feature/opensearch-doc
leiicamundi Oct 11, 2024
0bf7dca
tag modules
leiicamundi Oct 11, 2024
86957d5
Merge branch 'main' into feature/opensearch-doc
leiicamundi Oct 14, 2024
5a738cb
fix locals
leiicamundi Oct 14, 2024
e54b9e3
fix: parameters from modules examples
leiicamundi Oct 14, 2024
b8ab0e6
wip naming
leiicamundi Oct 14, 2024
4fcc9e0
fix irsa iam
leiicamundi Oct 14, 2024
622b051
fix files
leiicamundi Oct 14, 2024
67f9251
add helm values files
leiicamundi Oct 14, 2024
eb11cdf
update opensearch conf reference
leiicamundi Oct 14, 2024
94e7fd7
add irsa for all accounts
leiicamundi Oct 14, 2024
26a5086
update irsa values
leiicamundi Oct 14, 2024
2c52409
update std values
leiicamundi Oct 14, 2024
af60c9d
fix manifests
leiicamundi Oct 14, 2024
6856761
remove superuser for irsa connection
leiicamundi Oct 14, 2024
d436eda
move outputs
leiicamundi Oct 15, 2024
fd8e8ae
extract secrets from values
leiicamundi Oct 15, 2024
5e09b21
update values
leiicamundi Oct 15, 2024
f9af940
remove sg for default vpc
leiicamundi Oct 15, 2024
f1c714c
remove basic auth for opensearch
leiicamundi Oct 15, 2024
4f46e19
introduce one db per component
leiicamundi Oct 15, 2024
ad42773
update db
leiicamundi Oct 15, 2024
f00dc14
update db creation script
leiicamundi Oct 15, 2024
0760f39
update setup of database
leiicamundi Oct 15, 2024
0878a09
configure external db for each component
leiicamundi Oct 15, 2024
0a0511d
update database creation
leiicamundi Oct 15, 2024
894cd92
fix new line
leiicamundi Oct 15, 2024
178bc02
fix schema public permission
leiicamundi Oct 15, 2024
5fd124c
fix username
leiicamundi Oct 15, 2024
2eeb770
fix setup of the db
leiicamundi Oct 16, 2024
1960c3d
re-enable basic auth for OpenSearch
leiicamundi Oct 16, 2024
723ac46
implement arn for cluster
leiicamundi Oct 16, 2024
1cf36ce
fix anonymous
leiicamundi Oct 16, 2024
607bd30
fix cluster arn
leiicamundi Oct 16, 2024
226c157
add existing secret
leiicamundi Oct 16, 2024
cb05e5b
add port forwarding
leiicamundi Oct 16, 2024
5ace558
fix account names
leiicamundi Oct 16, 2024
cde6ebe
update keycloak irsa
leiicamundi Oct 16, 2024
ce2888e
add bash
leiicamundi Oct 17, 2024
61e7a30
add scripts
leiicamundi Oct 17, 2024
04a0ba1
add os fgac
leiicamundi Oct 17, 2024
c8b60f5
fix opensearch policy
leiicamundi Oct 17, 2024
795ed5e
fix opensearch role
leiicamundi Oct 17, 2024
42c43f6
update roles
leiicamundi Oct 18, 2024
6112fdf
introduce multi roles
leiicamundi Oct 18, 2024
252a912
fix go tests
leiicamundi Oct 18, 2024
800901e
fix go tests
leiicamundi Oct 18, 2024
a73f494
fix go tests
leiicamundi Oct 18, 2024
95a2196
fix auth iam
leiicamundi Oct 18, 2024
30c1f21
fix instructions
leiicamundi Oct 18, 2024
ee518f0
fix multiline
leiicamundi Oct 18, 2024
cfb6c8f
fix auroradb irsa
leiicamundi Oct 18, 2024
99ac48f
apply pre-commit
leiicamundi Oct 21, 2024
439fc4e
implement resourceidentifier
leiicamundi Oct 21, 2024
48e1940
fix module outputs
leiicamundi Oct 21, 2024
d9affa8
fix module outputs
leiicamundi Oct 21, 2024
fd221af
fix module outputs
leiicamundi Oct 21, 2024
f2a9c68
revert changes on dbidentifier
leiicamundi Oct 21, 2024
8ecda12
fix renovate update
leiicamundi Oct 21, 2024
15d205a
revert outputs
leiicamundi Oct 21, 2024
f0f3f63
Merge branch 'main' into feature/opensearch-doc
leiicamundi Oct 21, 2024
73a71e5
fix tests
leiicamundi Oct 21, 2024
5bcbed9
pin version
leiicamundi Oct 22, 2024
7620efc
fix tests
leiicamundi Oct 22, 2024
ccf1aa4
fix rds tests
leiicamundi Oct 23, 2024
afc37a4
explicitely configure resources
leiicamundi Oct 23, 2024
1c14689
add 8.7 folder
leiicamundi Oct 24, 2024
5b270a8
remove broken links
leiicamundi Oct 24, 2024
7d0bb2a
add a fix for storage class deletion
leiicamundi Oct 25, 2024
cfe4778
update reference config to let user set keys and bucket name
leiicamundi Oct 25, 2024
460276e
add user arn
leiicamundi Oct 25, 2024
b80844f
remove unused variable
leiicamundi Oct 25, 2024
e92cd2f
add an ignore message note
leiicamundi Oct 25, 2024
dcb196a
add directions for password strength
leiicamundi Oct 25, 2024
8af0389
fix 8.7 values
leiicamundi Oct 25, 2024
44e257c
fix default values for webmodeler with mandatory parameters
leiicamundi Oct 25, 2024
6c12e76
add console and modeler
leiicamundi Oct 25, 2024
50f5dfc
fix
leiicamundi Oct 25, 2024
c624e2a
fix keycloak url
leiicamundi Oct 25, 2024
7d71b2b
todo
leiicamundi Oct 25, 2024
9fe0d67
fix wrong port
leiicamundi Oct 25, 2024
0113717
re-align
leiicamundi Oct 25, 2024
053c241
Merge branch 'main' into feature/opensearch-doc
leiicamundi Oct 28, 2024
f55ce81
fix non-required
leiicamundi Oct 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 54 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ module "opensearch_domain" {

domain_name = "my-opensearch-domain"
subnet_ids = module.eks_cluster.private_subnet_ids
security_group_ids = module.eks_cluster.security_group_ids
Langleu marked this conversation as resolved.
Show resolved Hide resolved
vpc_id = module.eks_cluster.vpc_id
cidr_blocks = concat(module.eks_cluster.private_vpc_cidr_blocks, module.eks_cluster.public_vpc_cidr_blocks)

Expand All @@ -74,6 +73,34 @@ module "opensearch_domain" {
}
```

#### Deletion Known Issues

During the deletion process (`terraform destroy`) of the EKS Cluster, you may encounter an error message related to the `kubernetes_storage_class`:

````
Error: Get "http://localhost/apis/storage.k8s.io/v1/storageclasses/ebs-sc": dial tcp [::1]:80: connect: connection refused
│ with module.eks_cluster.kubernetes_storage_class_v1.ebs_sc,
│ on .terraform/modules/eks_cluster/modules/eks-cluster/cluster.tf line 156, in resource "kubernetes_storage_class_v1" "ebs_sc":
│ 156: resource "kubernetes_storage_class_v1" "ebs_sc" {
````

To resolve this issue, you can set the variable `create_ebs_gp3_default_storage_class` to `false`, which skips the creation of the `kubernetes_storage_class` resource. This helps to avoid dependency issues during deletion. Run the following command:

```bash
terraform destroy -var="create_ebs_gp3_default_storage_class=false"
```

If you still encounter the issue, you may need to manually remove the state for the storage class:

```bash
terraform state rm module.eks_cluster.kubernetes_storage_class_v1.ebs_sc
```

After performing these steps, re-run `terraform destroy` to complete the deletion process without further interruptions.

#### GitHub Actions

You can automate the deployment and deletion of the EKS cluster and Aurora database using GitHub Actions.
Expand Down Expand Up @@ -102,8 +129,7 @@ The Aurora module uses the following outputs from the EKS cluster module to defi
- `module.eks_cluster.oidc_provider_arn`: The ARN of the OIDC provider for the EKS cluster.
- `module.eks_cluster.oidc_provider_id`: The ID of the OIDC provider for the EKS cluster.
- `var.account_id`: Your AWS account id
- `var.aurora_cluster_name`: The name of the Aurora cluster to access
Here is the corrected version:
- `var.aurora_region`: Your Aurora AWS Region
- `var.aurora_irsa_username`: The username used to access AuroraDB. This username is different from the superuser. The user must also be created manually in the database to enable the IRSA connection, as described in [the steps below](#create-irsa-user-on-the-database).
- `var.aurora_namespace`: The kubernetes namespace to allow access
- `var.aurora_service_account`: The kubernetes ServiceAccount to allow access
Expand All @@ -113,7 +139,15 @@ You need to define the IAM role trust policy and access policy for Aurora. Here'
```hcl
module "postgresql" {
# ...
iam_aurora_access_policy = <<EOF
iam_roles_with_policies = [
{
role_name = "AuroraRole-your-cluster" # ensure uniqueness of this one

# Source: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.IAMPolicy.html
# Since the DbiResourceId may be unknown during the apply process, and because each instance of the RDS cluster contains its own DbiResourceId,
# we use the wildcard `dbuser:*` to apply to all database instances.

access_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
Expand All @@ -122,13 +156,13 @@ module "postgresql" {
"Action": [
"rds-db:connect"
],
"Resource": "arn:aws:rds-db:${module.eks_cluster.region}:${var.account_id}:dbuser:${var.aurora_cluster_name}/${var.aurora_irsa_username}"
"Resource": "arn:aws:rds-db:${var.aurora_region}:${var.account_id}:dbuser:*/${var.aurora_irsa_username}"
}
]
}
EOF

iam_role_trust_policy = <<EOF
trust_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
Expand All @@ -147,9 +181,9 @@ EOF
]
}
EOF
}
]

iam_aurora_role_name = "AuroraRole-your-cluster" # ensure uniqueness of this one
iam_create_aurora_role = true
iam_auth_enabled = true
# ...
}
Expand All @@ -164,7 +198,6 @@ echo "Creating IRSA DB user using admin user"
psql -h $AURORA_ENDPOINT -p $AURORA_PORT "sslmode=require dbname=$AURORA_DB_NAME user=$AURORA_USERNAME password=$AURORA_PASSWORD" \
-c "CREATE USER \"${AURORA_USERNAME_IRSA}\" WITH LOGIN;" \
-c "GRANT rds_iam TO \"${AURORA_USERNAME_IRSA}\";" \
-c "GRANT rds_superuser TO \"${AURORA_USERNAME_IRSA}\";" \
-c "GRANT ALL PRIVILEGES ON DATABASE \"${AURORA_DB_NAME}\" TO \"${AURORA_USERNAME_IRSA}\";" \
-c "SELECT aurora_version();" \
-c "SELECT version();" -c "\du"
Expand All @@ -181,16 +214,18 @@ The OpenSearch module uses the following outputs from the EKS cluster module to
- `module.eks_cluster.oidc_provider_arn`: The ARN of the OIDC provider for the EKS cluster.
- `module.eks_cluster.oidc_provider_id`: The ID of the OIDC provider for the EKS cluster.
- `var.account_id`: Your AWS account id
- `var.opensearch_region`: Your OpenSearch AWS Region
- `var.opensearch_domain_name`: The name of the OpenSearch domain to access
- `var.opensearch_namespace`: The kubernetes namespace to allow access
- `var.opensearch_service_account`: The kubernetes ServiceAccount to allow access

```hcl
module "opensearch_domain" {
# ...
iam_create_opensearch_role = true
iam_opensearch_role_name = "OpenSearchRole-your-cluster" # ensure uniqueness of this one
iam_opensearch_access_policy = <<EOF
iam_roles_with_policies = [
{
role_name = "OpenSearchRole-your-cluster" # ensure uniqueness of this one
access_policy =<<EOF
{
"Version": "2012-10-17",
"Statement": [
Expand All @@ -201,13 +236,13 @@ module "opensearch_domain" {
"es:ESHttpPut",
"es:ESHttpPost"
],
"Resource": "arn:aws:es:${module.eks_cluster.region}:${var.account_id}:domain/${var.opensearch_domain_name}/*"
"Resource": "arn:aws:es:${var.opensearch_region}:${var.account_id}:domain/${var.opensearch_domain_name}/*"
}
]
}
EOF

iam_role_trust_policy = <<EOF
trust_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
Expand All @@ -226,6 +261,9 @@ EOF
]
}
EOF
}
]

# ...
}
```
Expand All @@ -245,7 +283,7 @@ metadata:
annotations:
eks.amazonaws.com/role-arn: <arn:aws:iam:<YOUR-ACCOUNT-ID>:role/AuroraRole>
```
You can retrieve the role ARN from the module output: `aurora_role_arn`.
You can retrieve the role ARN from the module output: `aurora_iam_role_arns['Aurora-your-cluster']`.

**OpenSearch Service Account**

Expand All @@ -258,7 +296,7 @@ metadata:
annotations:
eks.amazonaws.com/role-arn: <arn:aws:iam:<YOUR-ACCOUNT-ID>:role/OpenSearchRole>
```
You can retrieve the role ARN from the module output: `opensearch_role_arn`.
You can retrieve the role ARN from the module output: `opensearch_iam_role_arns['OpenSearch-your-cluster']`.

## Support

Expand Down
4 changes: 4 additions & 0 deletions examples/camunda-8.6-irsa/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Camunda 8.6 on AWS EKS with IRSA

This folder describes the IaC of Camunda 8.6 on AWS EKS with IRSA.
Instructions can be found on the official documentation: https://docs.camunda.io/docs/self-managed/setup/deploy/amazon/amazon-eks/eks-terraform/
29 changes: 29 additions & 0 deletions examples/camunda-8.6-irsa/cluster.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
locals {
eks_cluster_name = "cluster-name-irsa" # Change this to a name of your choice
eks_cluster_region = "eu-west-2" # Change this to your desired AWS region
}

module "eks_cluster" {
source = "git::https://github.com/camunda/camunda-tf-eks-module//modules/eks-cluster?ref=3.0.0"

name = local.eks_cluster_name
region = local.eks_cluster_region

# Set CIDR ranges or use the defaults
cluster_service_ipv4_cidr = "10.190.0.0/16"
cluster_node_ipv4_cidr = "10.192.0.0/16"

# Default node type for the Kubernetes cluster
np_instance_types = ["m6i.xlarge"]
np_desired_node_count = 4
}

output "cert_manager_arn" {
value = module.eks_cluster.cert_manager_arn
description = "The Amazon Resource Name (ARN) of the AWS IAM Roles for Service Account mapping for the cert-manager"
}

output "external_dns_arn" {
value = module.eks_cluster.external_dns_arn
description = "The Amazon Resource Name (ARN) of the AWS IAM Roles for Service Account mapping for the external-dns"
}
17 changes: 17 additions & 0 deletions examples/camunda-8.6-irsa/config.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
terraform {
required_version = ">= 1.0"

# You can override the backend configuration; this is given as an example.
backend "s3" {
encrypt = true
}

required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.69"
}
}
}

provider "aws" {}
Loading
Loading