Skip to content

Commit e68c84a

Browse files
committed
init terraform-mendix-private-cloud
1 parent d88ad88 commit e68c84a

File tree

81 files changed

+9672
-247
lines changed

Some content is hidden

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

81 files changed

+9672
-247
lines changed

.gitignore

+8-35
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,17 @@
1-
build/
2-
plan.out
3-
plan.out.json
4-
5-
# Local .terraform directories
61
.terraform/
7-
8-
# .tfstate files
92
*.tfstate
10-
*.tfstate.*
11-
12-
# Crash log files
13-
crash.log
14-
15-
# Exclude all .tfvars files, which are likely to contain sentitive data, such as
16-
# password, private keys, and other secrets. These should not be part of version
17-
# control as they are data points which are potentially sensitive and subject
18-
# to change depending on the environment.
19-
#
20-
*.tfvars
21-
22-
# Ignore override files as they are usually used to override resources locally and so
23-
# are not checked in
3+
*.tfstate*
4+
_tfplan
5+
*.terraform.lock.hcl
246
override.tf
257
override.tf.json
268
*_override.tf
279
*_override.tf.json
28-
29-
# Include override files you do wish to add to version control using negated pattern
30-
#
31-
# !example_override.tf
32-
33-
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
34-
# example: *tfplan*
35-
36-
# Ignore CLI configuration files
10+
kubeconfig*
3711
.terraformrc
3812
terraform.rc
3913
.terraform.lock.hcl
40-
41-
go.mod
42-
go.sum
43-
44-
.DS_Store
14+
build/
15+
.DS_Store
16+
.idea
17+
temp.json

.header.md

+145-57
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,145 @@
1-
# Creating modules for AWS I&A Organization
2-
3-
This repo template is used to seed Terraform Module templates for the [AWS I&A GitHub organization](https://github.com/aws-ia). Usage of this template is allowed per included license. PRs to this template will be considered but are not guaranteed to be included. Consider creating an issue to discuss a feature you want to include before taking the time to create a PR.
4-
### TL;DR
5-
6-
1. [install pre-commit](https://pre-commit.com/)
7-
2. configure pre-commit: `pre-commit install`
8-
3. install required tools
9-
- [tflint](https://github.com/terraform-linters/tflint)
10-
- [tfsec](https://aquasecurity.github.io/tfsec/v1.0.11/)
11-
- [terraform-docs](https://github.com/terraform-docs/terraform-docs)
12-
- [golang](https://go.dev/doc/install) (for macos you can use `brew`)
13-
- [coreutils](https://www.gnu.org/software/coreutils/)
14-
15-
Write code according to [I&A module standards](https://aws-ia.github.io/standards-terraform/)
16-
17-
## Module Documentation
18-
19-
**Do not manually update README.md**. `terraform-docs` is used to generate README files. For any instructions an content, please update [.header.md](./.header.md) then simply run `terraform-docs ./` or allow the `pre-commit` to do so.
20-
21-
## Terratest
22-
23-
Please include tests to validate your examples/<> root modules, at a minimum. This can be accomplished with usually only slight modifications to the [boilerplate test provided in this template](./test/examples_basic_test.go)
24-
25-
### Configure and run Terratest
26-
27-
1. Install
28-
29-
[golang](https://go.dev/doc/install) (for macos you can use `brew`)
30-
2. Change directory into the test folder.
31-
32-
`cd test`
33-
3. Initialize your test
34-
35-
go mod init github.com/[github org]/[repository]
36-
37-
`go mod init github.com/aws-ia/terraform-aws-vpc`
38-
4. Run tidy
39-
40-
`git mod tidy`
41-
5. Install Terratest
42-
43-
`go get github.com/gruntwork-io/terratest/modules/terraform`
44-
6. Run test (You can have multiple test files).
45-
- Run all tests
46-
47-
`go test`
48-
- Run a specific test with a timeout
49-
50-
`go test -run TestExamplesBasic -timeout 45m`
51-
## Module Standards
52-
53-
For best practices and information on developing with Terraform, see the [I&A Module Standards](https://aws-ia.github.io/standards-terraform/)
54-
55-
## Continuous Integration
56-
57-
The I&A team uses AWS CodeBuild to perform continuous integration (CI) within the organization. Our CI uses the a repo's `.pre-commit-config.yaml` file as well as some other checks. All PRs with other CI will be rejected. See our [FAQ](https://aws-ia.github.io/standards-terraform/faq/#are-modules-protected-by-ci-automation) for more details.
1+
# Terraform Mendix Private Cloud
2+
3+
This repository represents an IaC project (Infractructure as Code) which facilitates the creation of repeatable and disposable environments meeting the requirements of Mendix for Private Cloud on AWS.
4+
5+
## Architecture diagram
6+
![image description](doc/deployment_guide/images/terraform-mendix-private-cloud-diagram.png)
7+
8+
## Prerequisites
9+
10+
### Mendix Private Cloud
11+
* Create your application on https://privatecloud.mendixcloud.com
12+
* Mendix Runtime Version >= 9.21
13+
* Register a new EKS Cluster
14+
* Add a new Connected Namespace called **mendix**
15+
* Retrieve the cluster id and the cluster secret in the *Installation* tab
16+
17+
### Terraform
18+
Provision a S3 bucket with your desired name and a DynamoDB table with the partition key `LockID` (String type), to store the state file and have a locking mechanism respectively.
19+
20+
* Install [Terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli)
21+
* An IAM user with programmatic access with at least the following IAM [permissions](deployment-policy.json)
22+
* Install [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
23+
* Configure AWS CLI with the `ACCESS_KEY_ID` and `SECRET_ACCESS_KEY` corresponding to the IAM user which has the aforementioned IAM permissions (execute `aws configure`)
24+
* Install [AWS IAM Authenticator](https://docs.aws.amazon.com/eks/latest/userguide/install-aws-iam-authenticator.html)
25+
* Install [kubectl](https://kubernetes.io/docs/tasks/tools/)
26+
* Install wget (required for Terraform eks module)
27+
* Edit the `providers.tf` as the following example:
28+
```
29+
terraform {
30+
backend "s3" {
31+
region = "eu-central-1"
32+
bucket = "state-bucket-state"
33+
key = "terraform.tfstate"
34+
dynamodb_table = "dynamodb-table-state"
35+
encrypt = true
36+
}
37+
```
38+
* Edit the `terraform.tfvars` as the following example: :
39+
```
40+
aws_region = ""
41+
domain_name = "project-name-example.com"
42+
certificate_expiration_email = "[email protected]"
43+
s3_bucket_name = "project-name"
44+
cluster_id = ""
45+
cluster_secret = ""
46+
environments_internal_names = ["app1", "app2", "app3"]
47+
```
48+
The number of applications deployed is handled by the `environments_internal_names` variable, those internal names are used during the environment creation :
49+
![image description](doc/deployment_guide/images/environments_internal_names.png)
50+
## Provisionning
51+
52+
To provision a new Mendix for Private Cloud environment, aka Mx4PC, execute the following commands:
53+
54+
```
55+
terraform init
56+
terraform apply
57+
```
58+
Once everything has been successfully provisioned, run the following command to retrieve the access credentials for your new cluster and automatically configure kubectl:
59+
60+
```
61+
aws eks --region $(terraform output -raw region) update-kubeconfig --name $(terraform output -raw cluster_name)
62+
```
63+
64+
Retrieve the aws_route53_zone_name_servers generated using the AWS Console in Route53 -> Hosted Zone, or at the end of the run using this command :
65+
66+
```
67+
terraform output aws_route53_zone_name_server
68+
```
69+
Depending on your provider, update your external Domain Name Registrar or Route53 registered domain with those values following this documentation [Route53 Documentation](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/dns-configuring.html).
70+
71+
Enable the External Secrets Store in the *Customization* tab of the Mendix for Private Cloud Portal Cluster Manager.
72+
![image description](doc/deployment_guide/images/secrets-store.png)
73+
## Security
74+
### Cluster endpoint
75+
Kubernetes API requests within your cluster's VPC (such as node to control plane communication) use the private VPC endpoint.
76+
Your cluster API server is accessible from the internet. You can, optionally, limit the CIDR blocks that can access the public endpoint as mentionned in the [Amazon EKS Documentation](https://docs.aws.amazon.com/eks/latest/userguide/cluster-endpoint.html) by setting up the ``allowed_ips`` variable.
77+
78+
### Encryption
79+
All the EBS volumes, the RDS PostgreSQL database and the S3 storage bucket are encrypted at rest. The end-to-end TLS encryption is handled at the Ingress NGINX Controller level, a certificate is generated for each app by cert-manager, configured with a Let’s Encrypt certificate issuer.
80+
81+
## Automatic scaling
82+
All the Amazon EKS nodes are placed in an Auto Scaling group, but it doesn’t install
83+
the [Kubernetes Cluster Autoscaler](https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler) by default. The Cluster Autoscaler provides automatic
84+
scale-up and scale-down by allowing Kubernetes to modify the Amazon EC2 Auto Scaling
85+
groups.
86+
87+
## Logging monitoring
88+
A basic logging and monitoring stack contaning Prometheus, Grafana, Loki and Promtail is provisionned by default, reacheable using this URL : https<span>://monitoring.{domain_name}
89+
90+
To retrieve the Grafana admin credentials :
91+
```
92+
terraform output -json grafana_admin_password
93+
```
94+
## Troubleshooting
95+
* For Mac M1 users, in order to fix this error:
96+
```
97+
│ Provider Terraform Registry 38 v2.2.0 does not have a
98+
│ package available for your current platform, darwin_arm64
99+
```
100+
Install [m1-terraform-provider-helper](https://github.com/kreuzwerker/m1-terraform-provider-helper):
101+
```
102+
brew install kreuzwerker/taps/m1-terraform-provider-helper
103+
m1-terraform-provider-helper activate
104+
m1-terraform-provider-helper install hashicorp/template -v v2.2.0
105+
```
106+
* Windows users:
107+
```
108+
terraform providers lock -platform=linux_amd64 -platform=darwin_amd64
109+
```
110+
* Mendix Agent/Operator not connected or misconfigured.
111+
112+
Retrieve the logs of the installer job :
113+
```
114+
kubectl logs job.batch/mxpc-cli-installer -n mendix
115+
```
116+
117+
Expected output :
118+
```
119+
-- Done-- Applying Kubernetes Secrets... Done!
120+
-- Applying Service Accounts... Done!
121+
-- Applying Storage Plans... Done!
122+
-- Applying Operator Patches... Done!
123+
-- Successfully applied all the configuration!
124+
operatorconfiguration.privatecloud.mendix.com/mendix-operator-configuration patched
125+
operatorconfiguration.privatecloud.mendix.com/mendix-operator-configuration patched
126+
operatorconfiguration.privatecloud.mendix.com/mendix-operator-configuration patched
127+
```
128+
* Reinstall the installer :
129+
```
130+
terraform destroy -target=helm_release.mendix_installer
131+
terraform plan; terraform apply --auto-approve
132+
```
133+
## Cleanup
134+
135+
To completely clean up your environment, destroy the Terraform modules using this reverse order.
136+
```
137+
terraform destroy -target="module.eks_blueprints_kubernetes_addons.module.ingress_nginx[0].module.helm_addon.helm_release.addon[0]" -auto-approve
138+
terraform destroy -target="module.eks_blueprints_kubernetes_addons.module.prometheus[0].module.helm_addon.helm_release.addon[0]" -auto-approve
139+
terraform destroy -target="module.eks_blueprints_kubernetes_addons" -auto-approve
140+
terraform destroy -auto-approve
141+
```
142+
143+
## License
144+
145+
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

.pre-commit-config.yaml

+6-7
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
fail_fast: false
33
minimum_pre_commit_version: "2.6.0"
44
repos:
5-
-
6-
repo: https://github.com/aws-ia/pre-commit-configs
7-
# To update run:
8-
# pre-commit autoupdate --freeze
9-
rev: 80ed3f0a164f282afaac0b6aec70e20f7e541932 # frozen: v1.5.0
10-
hooks:
11-
- id: aws-ia-meta-hook
5+
- repo: https://github.com/aws-ia/pre-commit-configs
6+
# To update run:
7+
# pre-commit autoupdate --freeze
8+
rev: 51b268040aacc4a4b1f0a3540722409cf93ac18d # frozen: v1.6.1
9+
hooks:
10+
- id: aws-ia-meta-hook

.terraform-docs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ sort:
1818

1919
output:
2020
file: README.md
21-
mode: replace
21+
mode: replace

.tflint.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
plugin "aws" {
55
enabled = true
6-
version = "0.14.0"
6+
version = "0.21.1"
77
source = "github.com/terraform-linters/tflint-ruleset-aws"
88
}
99

README.md

-87
This file was deleted.

charts/mendix-installer/Chart.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v2
2+
name: mendix-installer
3+
type: application
4+
description: A Helm chart to configure Mendix Private Cloud components using mxpc-cli
5+
6+
# This is the chart version. This version number should be incremented each time you make changes
7+
# to the chart and its templates, including the app version.
8+
version: 1.0.0
9+
10+
# This is the version number of the application being deployed. This version number should be
11+
# incremented each time you make changes to the application.
12+
appVersion: 1.0.0

0 commit comments

Comments
 (0)