Skip to content

Commit 7946ed5

Browse files
v23.11.1 (#31)
* fix: add --init switch * feat(do): rework tags * feat(aws): rework tags, bump versions * feat(aws): test kms_key_administrators
1 parent 86fce09 commit 7946ed5

31 files changed

+306
-190
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
**/.env
2323
.kube.config*
2424
**/backend.tf
25-
secrets
2625

2726
# ignore .pem
2827
*.pem

.tln.conf

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ module.exports = {
114114
args
115115
.prefix('TLN_CLOUDS')
116116
.option('backend', { describe: 'Defines which backend provider should be used (cloud, pg)', default: null, type: 'string' })
117+
.option('tenant', { describe: 'Tenant Id', default: null, type: 'string' })
117118
.option('state', { describe: 'Defines how store name will be built: project,provider,group,env,layer,tenant,<custom_string>', default: 'project,provider,group,env,layer', type: 'string' })
118119
.option('init', { describe: 'Run Terraform init', default: false, type: 'boolean' })
119120
.option('upgrade', { describe: 'Run Terraform upgrade mode for init', default: false, type: 'boolean' })
@@ -127,11 +128,9 @@ module.exports = {
127128
;
128129
},
129130
env: async (tln, env) => {
130-
// DO - provider layer
131-
//env.TF_VAR_domain_tag = 'tln-sh';
132-
//env.TF_VAR_private_key = path.join(__dirname, 'secrets', 'tln.sh.key');
133-
//env.TF_VAR_certificate_chain = path.join(__dirname, 'secrets', 'tln.sh.ca-bundle');
134-
//env.TF_VAR_leaf_certificate = path.join(__dirname, 'secrets', 'tln.sh.crt');
131+
if (env.TLN_CLOUDS_TENANT) {
132+
env.TF_VAR_tenant_id = env.TLN_CLOUDS_TENANT;
133+
}
135134
},
136135
dotenvs: async (tln) => ['.env'],
137136
inherits: async (tln) => [],
@@ -145,6 +144,11 @@ module.exports = {
145144
script.set(getScript(script.env, true));
146145
}
147146
},
147+
{ id: 'get-bastion', builder: async (tln, script) => {
148+
script.set([
149+
`tln exec -c 'cd network && terraform output bastion_remote_address'`,
150+
]);
151+
}},
148152
{ id: 'bridge', builder: async (tln, script) => {
149153
const port = script.env.TLN_CLOUDS_BRIDGE_PORT;
150154
switch (script.env.TLN_COMPONENT_ID) {
@@ -192,20 +196,25 @@ sshuttle --dns${daemon} -vr ${script.env.TLN_CLOUDS_BASTION} 0/0 --ssh-cmd 'ssh
192196
}
193197
},
194198
{ id: 'up', builder: async (tln, script) => {
199+
const tenant = (script.env.TF_VAR_tenant_id) ? `tln construct -- --backend cloud --init --apply --layers tenant --state project,provider,group,env,tenant --tenant ${script.env.TF_VAR_tenant_id}` : '';
195200
script.set([`
196-
tln construct -- --backend cloud --apply --layers provider --state project,provider
197-
tln construct -- --backend cloud --apply --layers group --state project,provider,group
198-
tln construct -- --backend cloud --apply --layers network,managed,app
199-
tln construct -- --backend cloud --apply --layers tenant --state project,provider,group,env,${script.env.TF_VAR_tenant_id}
201+
tln construct -- --backend cloud --init --apply --layers provider --state project,provider
202+
tln construct -- --backend cloud --init --apply --layers group --state project,provider,group
203+
tln construct -- --backend cloud --init --apply --layers network
204+
#tln sshuttle -- --bastion user@ip --deamon
205+
tln construct -- --backend cloud --init --apply --layers managed,app
206+
${tenant}
200207
`]);
201208
}
202209
},
203210
{ id: 'down', builder: async (tln, script) => {
211+
const tenant = (script.env.TF_VAR_tenant_id) ? `tln deconstruct -- --backend cloud --init --apply --layers tenant --state project,provider,group,env,tenant --tenant ${script.env.TF_VAR_tenant_id}` : ''
204212
script.set([`
205-
tln deconstruct -- --backend cloud --apply --layers tenant --state project,provider,group,env,${script.env.TF_VAR_tenant_id}
206-
tln deconstruct -- --backend cloud --apply --layers network,managed,app
207-
tln deconstruct -- --backend cloud --apply --layers group --state project,provider,group
208-
tln deconstruct -- --backend cloud --apply --layers provider --state project,provider
213+
#tln sshuttle -- --bastion user@ip --deamon
214+
${tenant}
215+
tln deconstruct -- --backend cloud --init --apply --layers network,managed,app
216+
tln deconstruct -- --backend cloud --init --apply --layers group --state project,provider,group
217+
tln deconstruct -- --backend cloud --init --apply --layers provider --state project,provider
209218
`]);
210219
}
211220
},

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* Install [tln](https://www.npmjs.com/package/tln-cli)
1717
* Goto **projects** folder from tln-cli installation above and clone repository
1818
```
19-
git clone --depth 1 --branch v23.9.0 git@github.com:project-talan/tln-clouds.git && cd tln-clouds
19+
git clone --depth 1 --branch v23.11.1 git@github.com:project-talan/tln-clouds.git && cd tln-clouds
2020
```
2121
> Important<br>
2222
> Commands below assume that Terraform Cloud is used as a storage for states<br/>

aws/.env.template

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
AWS_ACCESS_KEY_ID=
22
AWS_SECRET_ACCESS_KEY=
3-
AWS_SESSION_TOKEN=
4-
53
AWS_DEFAULT_REGION=eu-central-1
64

75
TF_VAR_aws_k8s_version=1.28

aws/app/main.tf

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
module "shared" {
2-
source = "../../shared"
3-
org_id = var.org_id
4-
project_id = var.project_id
5-
group_id = var.group_id
6-
env_id = var.env_id
7-
tenant_id = var.tenant_id
2+
source = "../../shared"
3+
org_id = var.org_id
4+
project_id = var.project_id
5+
group_id = var.group_id
6+
env_id = var.env_id
87
}

aws/app/variables.tf

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
variable "org_id" { type = string }
2-
variable "project_id" { type = string }
3-
variable "group_id" { type = string }
4-
variable "env_id" { type = string }
5-
variable "tenant_id" { type = string }
1+
variable "org_id" {
2+
type = string
3+
}
4+
variable "project_id" {
5+
type = string
6+
}
7+
variable "group_id" {
8+
type = string
9+
}
10+
variable "env_id" {
11+
type = string
12+
}

aws/group/main.tf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module "shared" {
2-
source = "../../shared"
3-
org_id = var.org_id
4-
project_id = var.project_id
5-
group_id = var.group_id
6-
env_id = var.env_id
7-
tenant_id = var.tenant_id
2+
source = "../../shared"
3+
org_id = var.org_id
4+
project_id = var.project_id
5+
group_id = var.group_id
86
}

aws/group/variables.tf

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
variable "org_id" { type = string }
2-
variable "project_id" { type = string }
3-
variable "group_id" { type = string }
4-
variable "env_id" { type = string }
5-
variable "tenant_id" { type = string }
1+
variable "org_id" {
2+
type = string
3+
}
4+
variable "project_id" {
5+
type = string
6+
}
7+
variable "group_id" {
8+
type = string
9+
}

aws/managed/main.tf

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
module "shared" {
2-
source = "../../shared"
3-
org_id = var.org_id
4-
project_id = var.project_id
5-
group_id = var.group_id
6-
env_id = var.env_id
7-
tenant_id = var.tenant_id
2+
source = "../../shared"
3+
org_id = var.org_id
4+
project_id = var.project_id
5+
group_id = var.group_id
6+
env_id = var.env_id
87
}
98

109
module "eks" {
1110
source = "terraform-aws-modules/eks/aws"
12-
version = "19.15.3"
11+
version = "19.19.0"
1312

1413
cluster_name = module.shared.k8s_name
1514
cluster_version = var.aws_k8s_version
1615
vpc_id = data.aws_vpc.main.id
1716
subnet_ids = data.aws_subnets.private.ids
1817

18+
//kms_key_administrators = []
19+
1920
eks_managed_node_group_defaults = {
2021
ami_type = "AL2_x86_64"
2122

aws/managed/variables.tf

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,31 @@
1-
variable "org_id" { type = string }
2-
variable "project_id" { type = string }
3-
variable "group_id" { type = string }
4-
variable "env_id" { type = string }
5-
variable "tenant_id" { type = string }
1+
variable "org_id" {
2+
type = string
3+
}
4+
variable "project_id" {
5+
type = string
6+
}
7+
variable "group_id" {
8+
type = string
9+
}
10+
variable "env_id" {
11+
type = string
12+
}
613

7-
variable "aws_k8s_version" { type = string }
8-
variable "aws_k8s_nodes_min" { type = string }
9-
variable "aws_k8s_nodes_desired" { type = string }
10-
variable "aws_k8s_nodes_max" { type = string }
11-
variable "aws_k8s_nodes_size" { type = string }
12-
variable "aws_k8s_nodes_disk" { type = string }
14+
variable "aws_k8s_version" {
15+
type = string
16+
}
17+
variable "aws_k8s_nodes_min" {
18+
type = string
19+
}
20+
variable "aws_k8s_nodes_desired" {
21+
type = string
22+
}
23+
variable "aws_k8s_nodes_max" {
24+
type = string
25+
}
26+
variable "aws_k8s_nodes_size" {
27+
type = string
28+
}
29+
variable "aws_k8s_nodes_disk" {
30+
type = string
31+
}

aws/network/main.tf

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
module "shared" {
2-
source = "../../shared"
3-
org_id = var.org_id
4-
project_id = var.project_id
5-
group_id = var.group_id
6-
env_id = var.env_id
7-
tenant_id = var.tenant_id
2+
source = "../../shared"
3+
org_id = var.org_id
4+
project_id = var.project_id
5+
group_id = var.group_id
6+
env_id = var.env_id
87
}
98

109
module "vpc" {
1110
source = "terraform-aws-modules/vpc/aws"
12-
version = "5.1.0"
11+
version = "5.1.2"
1312

1413
name = module.shared.vpc_name
1514
cidr = "10.0.0.0/16"

aws/network/variables.tf

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
variable "org_id" { type = string }
2-
variable "project_id" { type = string }
3-
variable "group_id" { type = string }
4-
variable "env_id" { type = string }
5-
variable "tenant_id" { type = string }
1+
variable "org_id" {
2+
type = string
3+
}
4+
variable "project_id" {
5+
type = string
6+
}
7+
variable "group_id" {
8+
type = string
9+
}
10+
variable "env_id" {
11+
type = string
12+
}

aws/provider/main.tf

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
module "shared" {
2-
source = "../../shared"
3-
org_id = var.org_id
4-
project_id = var.project_id
5-
group_id = var.group_id
6-
env_id = var.env_id
7-
tenant_id = var.tenant_id
2+
source = "../../shared"
3+
org_id = var.org_id
4+
project_id = var.project_id
85
}

aws/provider/variables.tf

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
variable "org_id" { type = string }
2-
variable "project_id" { type = string }
3-
variable "group_id" { type = string }
4-
variable "env_id" { type = string }
5-
variable "tenant_id" { type = string }
1+
variable "org_id" {
2+
type = string
3+
}
4+
variable "project_id" {
5+
type = string
6+
}
7+

aws/tenant/main.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module "shared" {
2-
source = "../../shared"
3-
org_id = var.org_id
4-
project_id = var.project_id
5-
group_id = var.group_id
6-
env_id = var.env_id
7-
tenant_id = var.tenant_id
2+
source = "../../shared"
3+
org_id = var.org_id
4+
project_id = var.project_id
5+
group_id = var.group_id
6+
env_id = var.env_id
7+
tenant_id = var.tenant_id
88
}

aws/tenant/variables.tf

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
variable "org_id" { type = string }
2-
variable "project_id" { type = string }
3-
variable "group_id" { type = string }
4-
variable "env_id" { type = string }
5-
variable "tenant_id" { type = string }
1+
variable "org_id" {
2+
type = string
3+
}
4+
variable "project_id" {
5+
type = string
6+
}
7+
variable "group_id" {
8+
type = string
9+
}
10+
variable "env_id" {
11+
type = string
12+
}
13+
variable "tenant_id" {
14+
type = string
15+
}

do/app/main.tf

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
module "shared" {
2-
source = "../../shared"
3-
org_id = var.org_id
4-
project_id = var.project_id
5-
group_id = var.group_id
6-
env_id = var.env_id
7-
tenant_id = var.tenant_id
2+
source = "../../shared"
3+
org_id = var.org_id
4+
project_id = var.project_id
5+
group_id = var.group_id
6+
env_id = var.env_id
87
}

do/app/variables.tf

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
variable "org_id" { type = string }
2-
variable "project_id" { type = string }
3-
variable "group_id" { type = string }
4-
variable "env_id" { type = string }
5-
variable "tenant_id" { type = string }
1+
variable "org_id" {
2+
type = string
3+
}
4+
variable "project_id" {
5+
type = string
6+
}
7+
variable "group_id" {
8+
type = string
9+
}
10+
variable "env_id" {
11+
type = string
12+
}
613

7-
variable "do_region" { type = string }
14+
variable "do_region" {
15+
type = string
16+
}

do/group/main.tf

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
module "shared" {
2-
source = "../../shared"
3-
org_id = var.org_id
4-
project_id = var.project_id
5-
group_id = var.group_id
6-
env_id = var.env_id
7-
tenant_id = var.tenant_id
2+
source = "../../shared"
3+
org_id = var.org_id
4+
project_id = var.project_id
5+
group_id = var.group_id
86
}
97

108
resource "digitalocean_tag" "group" {

0 commit comments

Comments
 (0)