Skip to content

Commit a587d47

Browse files
committed
cleanup and using backend.hcl to share vars
1 parent 7f75410 commit a587d47

File tree

3 files changed

+66
-15
lines changed

3 files changed

+66
-15
lines changed

examples/acme/README.md

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
# How To Configure Bootstrap
22

3-
For a working example see the [acme example](examples/acme/main.tf). One thing to note is the `source` setting needs to reference the Git URL rather than a path.
3+
For a working example see the [acme example](examples/acme/main.tf).
4+
5+
You can run the follwing commands inside the docker container produced by the release of this repo. Run the image with the following command (which will mount your ~/.aws/credentials into the docker container):
6+
7+
docker run -it -v ~/.aws:/root/.aws ghcr.io/mojaloop/iac-aws-bootstrap:currentver
8+
9+
You need to create the backend.hcl file by using the iac-aws-backend repo and setting the appropriate variables when prompted.
10+
11+
Copy the backend.hcl file into the same dir as the primary main.tf file.
12+
13+
Edit the main.tf file to set the appropriate domain variable (base domain) and the tenancy variable. This will create a zone for tenancy.domain so you will have hosts with FQDNs such as gitlab.tenancy.domain and wireguard.tenancy.domain, etc.
14+
15+
You can also change the number of zones to use if you wish to have the switch create worker nodes in different zones and have the load balancers balance accross those different zones. Or leave it at 1 and everything will be in the same zone.
16+
17+
You need to create a group that has admin access and that group must be set here:
18+
19+
iac_group_name = ....
20+
21+
After you finish modifying the settings in main.tf you will need to run the following commands:
22+
23+
1. terraform init --backend-config=backend.hcl
24+
2. terraform apply -var-file=backend.hcl
25+
3. cd post-config
26+
4. terraform init --backend-config=../backend.hcl
27+
5. terraform apply -var-file=../backend.hcl
28+
29+
Now you can log in to gitlab.tenancy.domain using root and the result of running this command from the main directory:
30+
31+
terraform output gitlab_root_pw
32+
33+
Use google authenticator or other appropriate app to configure MFA on gitlab for the root user.
434

5-
The Git URL to use is `git::[email protected]:mojaloop/iac-aws-bootstrap.git?ref=v0.1.0`

examples/acme/main.tf

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
module "bootstrap" {
2-
source = "git::https://github.com/mojaloop/iac-aws-bootstrap.git?ref=v2.1.4"
2+
source = "git::https://github.com/mojaloop/iac-aws-bootstrap.git?ref=v2beta"
33
tags = {
44
"Origin" = "Managed by Terraform"
55
"mojaloop/cost_center" = "oss-iac-test"
6-
"mojaloop/owner" = "dfry"
6+
"mojaloop/owner" = "jdoe"
77
"Tenant" = var.tenant
88
}
99

10-
domain = "mojatest.live" # The FQDN of the tenant
10+
domain = "mojatest.live"
1111
tenant = var.tenant # The Tenant name (probably the name of the customer - this should be the same as ths "tenant" above)
1212
region = var.region # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions
13-
environments = var.environments # Comma Separated list of environments in this tenant. e.g. ["dev","qa","test1"]
13+
environments = var.environments # Comma Separated list of environments in this tenant. e.g. ["dev","qa","test1"]
1414
gitlab_use_staging_letsencrypt = false
1515
iac_group_name = "iac_admin"
1616
enable_github_oauth = false
17-
github_oauth_id = "12abc8d17f07711165c5"
18-
github_oauth_secret = "60f7769649e0642393de91854fe299f504bb1046"
1917
gitlab_rbac_groups = var.gitlab_rbac_groups
2018
smtp_server_enable = true
19+
gitlab_version = "14.8.2"
20+
cidr_block_index = var.cidr_block_index
21+
max_number_availability_zones = 1
2122
}
2223

2324

@@ -26,6 +27,13 @@ variable "environments" {
2627
type = list(string)
2728
default = ["dev"]
2829
}
30+
variable "cidr_block_index" {
31+
description = "index for cidr block assignments"
32+
type = map(number)
33+
default = {
34+
"dev" = 0
35+
}
36+
}
2937
variable "gitlab_rbac_groups" {
3038
description = "list of groups to configure"
3139
type = list(string)
@@ -39,7 +47,7 @@ variable "region" {
3947
variable "tenant" {
4048
description = "tenant name"
4149
type = string
42-
default = "infra4"
50+
default = "tenancy1"
4351
}
4452
############################################### DO NOT EDIT BELOW THIS LINE #############################################
4553

@@ -200,4 +208,8 @@ output "ses_user" {
200208
output "ses_pw" {
201209
value = module.bootstrap.ses_pw
202210
sensitive = true
211+
}
212+
output "availability_zones" {
213+
description = "azs used in tenancy"
214+
value = module.bootstrap.availability_zones
203215
}

examples/acme/post-config/main.tf

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
module "init-gitlab" {
2-
source = "git::https://github.com/mojaloop/iac-shared-modules.git//gitlab/init-config?ref=v2.1.4"
3-
iac_user_key_secret = data.terraform_remote_state.tenant.outputs.iac_user_key_id
4-
iac_user_key_id = data.terraform_remote_state.tenant.outputs.iac_user_key_secret
2+
source = "git::https://github.com/mojaloop/iac-shared-modules.git//gitlab/init-config?ref=v2.1.14"
3+
iac_user_key_secret = data.terraform_remote_state.tenant.outputs.iac_user_key_secret
4+
iac_user_key_id = data.terraform_remote_state.tenant.outputs.iac_user_key_id
55
group_list = data.terraform_remote_state.tenant.outputs.gitlab_rbac_groups
66
env_list = data.terraform_remote_state.tenant.outputs.environments
77
root_token = data.terraform_remote_state.tenant.outputs.gitlab_root_token
88
gitlab_url = "https://${data.terraform_remote_state.tenant.outputs.gitlab_hostname}"
9+
two_factor_grace_period = 0
910
}
1011

1112

@@ -20,8 +21,17 @@ terraform {
2021
data "terraform_remote_state" "tenant" {
2122
backend = "s3"
2223
config = {
23-
region = "eu-west-1"
24-
bucket = "infra4-mojaloop-state"
24+
region = var.region
25+
bucket = var.bucket
2526
key = "bootstrap/terraform.tfstate"
2627
}
27-
}
28+
}
29+
30+
variable "region" {
31+
description = "region to install in"
32+
type = string
33+
}
34+
variable "bucket" {
35+
description = "bucket name"
36+
type = string
37+
}

0 commit comments

Comments
 (0)