@intentius/behold 0.29.25 → 0.29.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +3 -1
- package/demos.json +15 -0
- package/dist/cli.js +697 -371
- package/example-choudoufu-estate/README.md +2 -2
- package/example-choudoufu-estate/scripts/choudoufu-up.sh +2 -2
- package/example-terralith/README.md +33 -0
- package/example-terralith/phases/adopt/migrations/adopt.yml +12 -0
- package/example-terralith/phases/adopt/terralith/main.tf +138 -0
- package/example-terralith/phases/plan/team-a/main.tf +58 -0
- package/example-terralith/phases/plan/team-b/main.tf +58 -0
- package/example-terralith/phases/plan/team-c/main.tf +58 -0
- package/example-terralith/phases/plan/terralith/main.tf +32 -0
- package/example-terralith/phases/split/migrations/split.yml +29 -0
- package/example-terralith/phases/split/team-a/main.tf +52 -0
- package/example-terralith/phases/split/team-b/main.tf +52 -0
- package/example-terralith/phases/split/team-c/main.tf +52 -0
- package/example-terralith/phases/split/terralith/main.tf +27 -0
- package/example-terralith/scripts/lib.sh +65 -0
- package/example-terralith/scripts/terralith-down.sh +9 -0
- package/example-terralith/scripts/terralith-step.sh +139 -0
- package/example-terralith/scripts/terralith-up.sh +50 -0
- package/example-terralith/terralith/main.tf +141 -0
- package/package.json +2 -1
- package/web/app.js +83 -9
- package/web/identity-mark.js +61 -0
- package/web/identity-mark.test.js +32 -0
- package/web/pending.js +54 -0
- package/web/pending.test.js +47 -1
- package/web/terralith-steps.js +142 -0
- package/web/terralith-steps.test.js +97 -0
- package/web/terralith.html +125 -0
- package/web/terralith.js +301 -0
- /package/example-choudoufu-estate/monolith/{carve.json → split.json} +0 -0
|
@@ -18,7 +18,7 @@ in the choudoufu repo), copied:
|
|
|
18
18
|
the monolith does not, and team-b reads it through a data source filtered
|
|
19
19
|
on team-a's marker tags, the cross-estate reference `live-check -json`
|
|
20
20
|
states, drawn as an edge between the two boxes.
|
|
21
|
-
- **monolith/
|
|
21
|
+
- **monolith/split.json.** The split plan: team-a's five taggable resources move to
|
|
22
22
|
`tlmig-sample-team-a`. The scope panel shows each move with the
|
|
23
23
|
`choudoufu live-mv` line to run and a link to the morph; behold never runs
|
|
24
24
|
the write.
|
|
@@ -41,7 +41,7 @@ choudoufu live-mv -from-estate=tlmig-sample-monolith aws_iam_role.team_a aws_iam
|
|
|
41
41
|
|
|
42
42
|
Reload the overlay: the role and its two followers are green in team-a's box,
|
|
43
43
|
the monolith's card for it reads *owned by tlmig-sample-team-a*, and
|
|
44
|
-
`/api/choudoufu/
|
|
44
|
+
`/api/choudoufu/split?plan=split.json&receipt=1` says `moved`. Apply team-a
|
|
45
45
|
afterwards to bring its VPC up, and team-b's read resolves.
|
|
46
46
|
|
|
47
47
|
`bash scripts/choudoufu-down.sh` removes the container. The `.terraform/`
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# (the AWS emulator), provider schemas in each estate copy, and the terralith
|
|
4
4
|
# applied — one estate with three teams' worth of IAM and log groups in it,
|
|
5
5
|
# the shape the live-mv workbench splits. The team estates start empty: their
|
|
6
|
-
# declared resources are the monolith's, and the plan in monolith/
|
|
6
|
+
# declared resources are the monolith's, and the plan in monolith/split.json
|
|
7
7
|
# says which move where.
|
|
8
8
|
#
|
|
9
9
|
# Scratch discipline (behold's src/scratch.ts): the container is named
|
|
@@ -80,4 +80,4 @@ else
|
|
|
80
80
|
echo "→ no 'aws' on PATH, so the adoptable card is skipped; everything else stands up"
|
|
81
81
|
fi
|
|
82
82
|
|
|
83
|
-
echo "choudoufu-estate demo: up. behold serves it next; the plan in monolith/
|
|
83
|
+
echo "choudoufu-estate demo: up. behold serves it next; the plan in monolith/split.json moves team-a's resources out."
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# terralith: adopt and split, on a scratch floci
|
|
2
|
+
|
|
3
|
+
One Terraform root that holds everything, taken to four choudoufu estates in
|
|
4
|
+
two reviewed steps. [choudoufu](https://github.com/INTENTIUS/choudoufu) is the
|
|
5
|
+
OpenTofu fork for AWS and Kubernetes whose ownership lives on each resource as
|
|
6
|
+
two tags, `tofu-estate` and `tofu-address`.
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npx @intentius/behold demo terralith # Docker, curl and choudoufu 0.28.0 or newer
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The page is `http://localhost:4600/terralith`. It reads the files each phase
|
|
13
|
+
leaves in `snapshots/`, and shows the next phase's line for you to run here.
|
|
14
|
+
|
|
15
|
+
| Phase | You run | What happens |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| 1. Stock | `bash scripts/terralith-up.sh` (the demo runs it) | a floci on 127.0.0.1:4652, a state bucket, and `terralith/` applied the stock way: 23 resources in one state file |
|
|
18
|
+
| 2. Adopt | `bash scripts/terralith-step.sh adopt` | terragucci's `backends:` migration: the backend block becomes a live block (`phases/adopt/`), `choudoufu live-import` reads the state once and stamps the two tags on each resource it verifies |
|
|
19
|
+
| 3. Split | `bash scripts/terralith-step.sh split` | terragucci's `moves:` migration: three team roots (`phases/split/`), and `choudoufu live-mv -from-estate` moves each team's resources into the team's estate, one tag write each, recorded in `split.json` |
|
|
20
|
+
| 4. Plan | `bash scripts/terralith-step.sh plan` | one change across the estates (`phases/plan/`): the terralith outputs `log_retention_days`, each team's first log group reads it, `live-cone` gives each team's cone, the team roots plan against the terralith's planned output with `-estate-outputs-from` in one `live-plan-set`, and `live-summary` folds the three changes into one group. Nothing is applied |
|
|
21
|
+
|
|
22
|
+
From adopt on, each card carries a tag. A filled tag means the resource wears the
|
|
23
|
+
marker; an outlined one means it has no tags argument and rides the role it
|
|
24
|
+
belongs to. The word beside it says how choudoufu's plan found the resource:
|
|
25
|
+
`marker`, by the tag sweep, or `derived`, by the name the code gives it. A
|
|
26
|
+
named resource reads `derived` and wears the marker too.
|
|
27
|
+
|
|
28
|
+
The state file stays in the bucket as it was after adopt. Each stamp and
|
|
29
|
+
each retag is its own tag write.
|
|
30
|
+
|
|
31
|
+
`bash scripts/terralith-down.sh` removes the container. Set
|
|
32
|
+
`TERRALITH_CONTAINER` and `TERRALITH_PORT` for another name and port, or
|
|
33
|
+
`CHOUDOUFU_BIN` for a choudoufu that is not on PATH.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Adopt the terralith: its state moves onto the resources as markers.
|
|
2
|
+
# choudoufu live-import reads the old state once and stamps tofu-estate and
|
|
3
|
+
# tofu-address on every resource it verifies. The old state stays where it is.
|
|
4
|
+
backends:
|
|
5
|
+
- root: terralith
|
|
6
|
+
from:
|
|
7
|
+
backend: s3
|
|
8
|
+
config:
|
|
9
|
+
bucket: terralith-state
|
|
10
|
+
key: terralith/terraform.tfstate
|
|
11
|
+
region: us-east-1
|
|
12
|
+
use_lockfile: true
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
terraform {
|
|
2
|
+
required_providers {
|
|
3
|
+
aws = {
|
|
4
|
+
source = "hashicorp/aws"
|
|
5
|
+
version = "= 6.59.0"
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
live {
|
|
9
|
+
estate = "terralith"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
provider "aws" {
|
|
14
|
+
region = "us-east-1"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# ---- network ----
|
|
18
|
+
resource "aws_vpc" "main" {
|
|
19
|
+
cidr_block = "10.42.0.0/16"
|
|
20
|
+
tags = { Name = "terralith-main" }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
resource "aws_subnet" "app" {
|
|
24
|
+
vpc_id = aws_vpc.main.id
|
|
25
|
+
cidr_block = "10.42.1.0/24"
|
|
26
|
+
tags = { Name = "terralith-app" }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# ---- team-a ----
|
|
30
|
+
resource "aws_iam_role" "team_a" {
|
|
31
|
+
name = "terralith-team-a-role"
|
|
32
|
+
assume_role_policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Principal = { Service = "ec2.amazonaws.com" }, Action = "sts:AssumeRole" }] })
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
resource "aws_iam_role_policy" "team_a_inline" {
|
|
36
|
+
name = "terralith-team-a-inline"
|
|
37
|
+
role = aws_iam_role.team_a.id
|
|
38
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:CreateLogStream"], Resource = "*" }] })
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
resource "aws_iam_policy" "team_a" {
|
|
42
|
+
name = "terralith-team-a-policy"
|
|
43
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:PutLogEvents"], Resource = "*" }] })
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
resource "aws_iam_role_policy_attachment" "team_a" {
|
|
47
|
+
role = aws_iam_role.team_a.name
|
|
48
|
+
policy_arn = aws_iam_policy.team_a.arn
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
resource "aws_cloudwatch_log_group" "team_a_0" {
|
|
52
|
+
name = "/terralith/team-a/svc-0"
|
|
53
|
+
retention_in_days = 7
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
resource "aws_cloudwatch_log_group" "team_a_1" {
|
|
57
|
+
name = "/terralith/team-a/svc-1"
|
|
58
|
+
retention_in_days = 7
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
resource "aws_cloudwatch_log_group" "team_a_2" {
|
|
62
|
+
name = "/terralith/team-a/svc-2"
|
|
63
|
+
retention_in_days = 7
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
# ---- team-b ----
|
|
67
|
+
resource "aws_iam_role" "team_b" {
|
|
68
|
+
name = "terralith-team-b-role"
|
|
69
|
+
assume_role_policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Principal = { Service = "ec2.amazonaws.com" }, Action = "sts:AssumeRole" }] })
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
resource "aws_iam_role_policy" "team_b_inline" {
|
|
73
|
+
name = "terralith-team-b-inline"
|
|
74
|
+
role = aws_iam_role.team_b.id
|
|
75
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:CreateLogStream"], Resource = "*" }] })
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
resource "aws_iam_policy" "team_b" {
|
|
79
|
+
name = "terralith-team-b-policy"
|
|
80
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:PutLogEvents"], Resource = "*" }] })
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
resource "aws_iam_role_policy_attachment" "team_b" {
|
|
84
|
+
role = aws_iam_role.team_b.name
|
|
85
|
+
policy_arn = aws_iam_policy.team_b.arn
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
resource "aws_cloudwatch_log_group" "team_b_0" {
|
|
89
|
+
name = "/terralith/team-b/svc-0"
|
|
90
|
+
retention_in_days = 7
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
resource "aws_cloudwatch_log_group" "team_b_1" {
|
|
94
|
+
name = "/terralith/team-b/svc-1"
|
|
95
|
+
retention_in_days = 7
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
resource "aws_cloudwatch_log_group" "team_b_2" {
|
|
99
|
+
name = "/terralith/team-b/svc-2"
|
|
100
|
+
retention_in_days = 7
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
# ---- team-c ----
|
|
104
|
+
resource "aws_iam_role" "team_c" {
|
|
105
|
+
name = "terralith-team-c-role"
|
|
106
|
+
assume_role_policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Principal = { Service = "ec2.amazonaws.com" }, Action = "sts:AssumeRole" }] })
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
resource "aws_iam_role_policy" "team_c_inline" {
|
|
110
|
+
name = "terralith-team-c-inline"
|
|
111
|
+
role = aws_iam_role.team_c.id
|
|
112
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:CreateLogStream"], Resource = "*" }] })
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
resource "aws_iam_policy" "team_c" {
|
|
116
|
+
name = "terralith-team-c-policy"
|
|
117
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:PutLogEvents"], Resource = "*" }] })
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
resource "aws_iam_role_policy_attachment" "team_c" {
|
|
121
|
+
role = aws_iam_role.team_c.name
|
|
122
|
+
policy_arn = aws_iam_policy.team_c.arn
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
resource "aws_cloudwatch_log_group" "team_c_0" {
|
|
126
|
+
name = "/terralith/team-c/svc-0"
|
|
127
|
+
retention_in_days = 7
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
resource "aws_cloudwatch_log_group" "team_c_1" {
|
|
131
|
+
name = "/terralith/team-c/svc-1"
|
|
132
|
+
retention_in_days = 7
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
resource "aws_cloudwatch_log_group" "team_c_2" {
|
|
136
|
+
name = "/terralith/team-c/svc-2"
|
|
137
|
+
retention_in_days = 7
|
|
138
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
terraform {
|
|
2
|
+
required_providers {
|
|
3
|
+
aws = {
|
|
4
|
+
source = "hashicorp/aws"
|
|
5
|
+
version = "= 6.59.0"
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
live {
|
|
9
|
+
estate = "team-a"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
provider "aws" {
|
|
14
|
+
region = "us-east-1"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# ---- team-a ----
|
|
18
|
+
resource "aws_iam_role" "team_a" {
|
|
19
|
+
name = "terralith-team-a-role"
|
|
20
|
+
assume_role_policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Principal = { Service = "ec2.amazonaws.com" }, Action = "sts:AssumeRole" }] })
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
resource "aws_iam_role_policy" "team_a_inline" {
|
|
24
|
+
name = "terralith-team-a-inline"
|
|
25
|
+
role = aws_iam_role.team_a.id
|
|
26
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:CreateLogStream"], Resource = "*" }] })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
resource "aws_iam_policy" "team_a" {
|
|
30
|
+
name = "terralith-team-a-policy"
|
|
31
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:PutLogEvents"], Resource = "*" }] })
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
resource "aws_iam_role_policy_attachment" "team_a" {
|
|
35
|
+
role = aws_iam_role.team_a.name
|
|
36
|
+
policy_arn = aws_iam_policy.team_a.arn
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
resource "aws_cloudwatch_log_group" "team_a_0" {
|
|
40
|
+
name = "/terralith/team-a/svc-0"
|
|
41
|
+
retention_in_days = data.terraform_estate_outputs.platform.values.log_retention_days
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
resource "aws_cloudwatch_log_group" "team_a_1" {
|
|
45
|
+
name = "/terralith/team-a/svc-1"
|
|
46
|
+
retention_in_days = 7
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
resource "aws_cloudwatch_log_group" "team_a_2" {
|
|
50
|
+
name = "/terralith/team-a/svc-2"
|
|
51
|
+
retention_in_days = 7
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# ---- the platform's shared settings ----
|
|
55
|
+
data "terraform_estate_outputs" "platform" {
|
|
56
|
+
estate = "terralith"
|
|
57
|
+
names = ["log_retention_days"]
|
|
58
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
terraform {
|
|
2
|
+
required_providers {
|
|
3
|
+
aws = {
|
|
4
|
+
source = "hashicorp/aws"
|
|
5
|
+
version = "= 6.59.0"
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
live {
|
|
9
|
+
estate = "team-b"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
provider "aws" {
|
|
14
|
+
region = "us-east-1"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# ---- team-b ----
|
|
18
|
+
resource "aws_iam_role" "team_b" {
|
|
19
|
+
name = "terralith-team-b-role"
|
|
20
|
+
assume_role_policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Principal = { Service = "ec2.amazonaws.com" }, Action = "sts:AssumeRole" }] })
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
resource "aws_iam_role_policy" "team_b_inline" {
|
|
24
|
+
name = "terralith-team-b-inline"
|
|
25
|
+
role = aws_iam_role.team_b.id
|
|
26
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:CreateLogStream"], Resource = "*" }] })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
resource "aws_iam_policy" "team_b" {
|
|
30
|
+
name = "terralith-team-b-policy"
|
|
31
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:PutLogEvents"], Resource = "*" }] })
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
resource "aws_iam_role_policy_attachment" "team_b" {
|
|
35
|
+
role = aws_iam_role.team_b.name
|
|
36
|
+
policy_arn = aws_iam_policy.team_b.arn
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
resource "aws_cloudwatch_log_group" "team_b_0" {
|
|
40
|
+
name = "/terralith/team-b/svc-0"
|
|
41
|
+
retention_in_days = data.terraform_estate_outputs.platform.values.log_retention_days
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
resource "aws_cloudwatch_log_group" "team_b_1" {
|
|
45
|
+
name = "/terralith/team-b/svc-1"
|
|
46
|
+
retention_in_days = 7
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
resource "aws_cloudwatch_log_group" "team_b_2" {
|
|
50
|
+
name = "/terralith/team-b/svc-2"
|
|
51
|
+
retention_in_days = 7
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# ---- the platform's shared settings ----
|
|
55
|
+
data "terraform_estate_outputs" "platform" {
|
|
56
|
+
estate = "terralith"
|
|
57
|
+
names = ["log_retention_days"]
|
|
58
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
terraform {
|
|
2
|
+
required_providers {
|
|
3
|
+
aws = {
|
|
4
|
+
source = "hashicorp/aws"
|
|
5
|
+
version = "= 6.59.0"
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
live {
|
|
9
|
+
estate = "team-c"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
provider "aws" {
|
|
14
|
+
region = "us-east-1"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# ---- team-c ----
|
|
18
|
+
resource "aws_iam_role" "team_c" {
|
|
19
|
+
name = "terralith-team-c-role"
|
|
20
|
+
assume_role_policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Principal = { Service = "ec2.amazonaws.com" }, Action = "sts:AssumeRole" }] })
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
resource "aws_iam_role_policy" "team_c_inline" {
|
|
24
|
+
name = "terralith-team-c-inline"
|
|
25
|
+
role = aws_iam_role.team_c.id
|
|
26
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:CreateLogStream"], Resource = "*" }] })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
resource "aws_iam_policy" "team_c" {
|
|
30
|
+
name = "terralith-team-c-policy"
|
|
31
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:PutLogEvents"], Resource = "*" }] })
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
resource "aws_iam_role_policy_attachment" "team_c" {
|
|
35
|
+
role = aws_iam_role.team_c.name
|
|
36
|
+
policy_arn = aws_iam_policy.team_c.arn
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
resource "aws_cloudwatch_log_group" "team_c_0" {
|
|
40
|
+
name = "/terralith/team-c/svc-0"
|
|
41
|
+
retention_in_days = data.terraform_estate_outputs.platform.values.log_retention_days
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
resource "aws_cloudwatch_log_group" "team_c_1" {
|
|
45
|
+
name = "/terralith/team-c/svc-1"
|
|
46
|
+
retention_in_days = 7
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
resource "aws_cloudwatch_log_group" "team_c_2" {
|
|
50
|
+
name = "/terralith/team-c/svc-2"
|
|
51
|
+
retention_in_days = 7
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# ---- the platform's shared settings ----
|
|
55
|
+
data "terraform_estate_outputs" "platform" {
|
|
56
|
+
estate = "terralith"
|
|
57
|
+
names = ["log_retention_days"]
|
|
58
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
terraform {
|
|
2
|
+
required_providers {
|
|
3
|
+
aws = {
|
|
4
|
+
source = "hashicorp/aws"
|
|
5
|
+
version = "= 6.59.0"
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
live {
|
|
9
|
+
estate = "terralith"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
provider "aws" {
|
|
14
|
+
region = "us-east-1"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# ---- network ----
|
|
18
|
+
resource "aws_vpc" "main" {
|
|
19
|
+
cidr_block = "10.42.0.0/16"
|
|
20
|
+
tags = { Name = "terralith-main" }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
resource "aws_subnet" "app" {
|
|
24
|
+
vpc_id = aws_vpc.main.id
|
|
25
|
+
cidr_block = "10.42.1.0/24"
|
|
26
|
+
tags = { Name = "terralith-app" }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# ---- shared settings, read by the team estates ----
|
|
30
|
+
output "log_retention_days" {
|
|
31
|
+
value = 14
|
|
32
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Split the terralith: each team's resources move to the team's own estate.
|
|
2
|
+
# choudoufu live-mv -from-estate rewrites each resource's markers, run in
|
|
3
|
+
# the root it moves to. One tag write per resource; the untaggable children
|
|
4
|
+
# (inline policies, attachments) follow their role with no write of their own.
|
|
5
|
+
moves:
|
|
6
|
+
- from: terralith
|
|
7
|
+
to: team-a
|
|
8
|
+
addresses:
|
|
9
|
+
- aws_iam_role.team_a
|
|
10
|
+
- aws_iam_policy.team_a
|
|
11
|
+
- aws_cloudwatch_log_group.team_a_0
|
|
12
|
+
- aws_cloudwatch_log_group.team_a_1
|
|
13
|
+
- aws_cloudwatch_log_group.team_a_2
|
|
14
|
+
- from: terralith
|
|
15
|
+
to: team-b
|
|
16
|
+
addresses:
|
|
17
|
+
- aws_iam_role.team_b
|
|
18
|
+
- aws_iam_policy.team_b
|
|
19
|
+
- aws_cloudwatch_log_group.team_b_0
|
|
20
|
+
- aws_cloudwatch_log_group.team_b_1
|
|
21
|
+
- aws_cloudwatch_log_group.team_b_2
|
|
22
|
+
- from: terralith
|
|
23
|
+
to: team-c
|
|
24
|
+
addresses:
|
|
25
|
+
- aws_iam_role.team_c
|
|
26
|
+
- aws_iam_policy.team_c
|
|
27
|
+
- aws_cloudwatch_log_group.team_c_0
|
|
28
|
+
- aws_cloudwatch_log_group.team_c_1
|
|
29
|
+
- aws_cloudwatch_log_group.team_c_2
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
terraform {
|
|
2
|
+
required_providers {
|
|
3
|
+
aws = {
|
|
4
|
+
source = "hashicorp/aws"
|
|
5
|
+
version = "= 6.59.0"
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
live {
|
|
9
|
+
estate = "team-a"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
provider "aws" {
|
|
14
|
+
region = "us-east-1"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# ---- team-a ----
|
|
18
|
+
resource "aws_iam_role" "team_a" {
|
|
19
|
+
name = "terralith-team-a-role"
|
|
20
|
+
assume_role_policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Principal = { Service = "ec2.amazonaws.com" }, Action = "sts:AssumeRole" }] })
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
resource "aws_iam_role_policy" "team_a_inline" {
|
|
24
|
+
name = "terralith-team-a-inline"
|
|
25
|
+
role = aws_iam_role.team_a.id
|
|
26
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:CreateLogStream"], Resource = "*" }] })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
resource "aws_iam_policy" "team_a" {
|
|
30
|
+
name = "terralith-team-a-policy"
|
|
31
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:PutLogEvents"], Resource = "*" }] })
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
resource "aws_iam_role_policy_attachment" "team_a" {
|
|
35
|
+
role = aws_iam_role.team_a.name
|
|
36
|
+
policy_arn = aws_iam_policy.team_a.arn
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
resource "aws_cloudwatch_log_group" "team_a_0" {
|
|
40
|
+
name = "/terralith/team-a/svc-0"
|
|
41
|
+
retention_in_days = 7
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
resource "aws_cloudwatch_log_group" "team_a_1" {
|
|
45
|
+
name = "/terralith/team-a/svc-1"
|
|
46
|
+
retention_in_days = 7
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
resource "aws_cloudwatch_log_group" "team_a_2" {
|
|
50
|
+
name = "/terralith/team-a/svc-2"
|
|
51
|
+
retention_in_days = 7
|
|
52
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
terraform {
|
|
2
|
+
required_providers {
|
|
3
|
+
aws = {
|
|
4
|
+
source = "hashicorp/aws"
|
|
5
|
+
version = "= 6.59.0"
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
live {
|
|
9
|
+
estate = "team-b"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
provider "aws" {
|
|
14
|
+
region = "us-east-1"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# ---- team-b ----
|
|
18
|
+
resource "aws_iam_role" "team_b" {
|
|
19
|
+
name = "terralith-team-b-role"
|
|
20
|
+
assume_role_policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Principal = { Service = "ec2.amazonaws.com" }, Action = "sts:AssumeRole" }] })
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
resource "aws_iam_role_policy" "team_b_inline" {
|
|
24
|
+
name = "terralith-team-b-inline"
|
|
25
|
+
role = aws_iam_role.team_b.id
|
|
26
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:CreateLogStream"], Resource = "*" }] })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
resource "aws_iam_policy" "team_b" {
|
|
30
|
+
name = "terralith-team-b-policy"
|
|
31
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:PutLogEvents"], Resource = "*" }] })
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
resource "aws_iam_role_policy_attachment" "team_b" {
|
|
35
|
+
role = aws_iam_role.team_b.name
|
|
36
|
+
policy_arn = aws_iam_policy.team_b.arn
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
resource "aws_cloudwatch_log_group" "team_b_0" {
|
|
40
|
+
name = "/terralith/team-b/svc-0"
|
|
41
|
+
retention_in_days = 7
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
resource "aws_cloudwatch_log_group" "team_b_1" {
|
|
45
|
+
name = "/terralith/team-b/svc-1"
|
|
46
|
+
retention_in_days = 7
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
resource "aws_cloudwatch_log_group" "team_b_2" {
|
|
50
|
+
name = "/terralith/team-b/svc-2"
|
|
51
|
+
retention_in_days = 7
|
|
52
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
terraform {
|
|
2
|
+
required_providers {
|
|
3
|
+
aws = {
|
|
4
|
+
source = "hashicorp/aws"
|
|
5
|
+
version = "= 6.59.0"
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
live {
|
|
9
|
+
estate = "team-c"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
provider "aws" {
|
|
14
|
+
region = "us-east-1"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# ---- team-c ----
|
|
18
|
+
resource "aws_iam_role" "team_c" {
|
|
19
|
+
name = "terralith-team-c-role"
|
|
20
|
+
assume_role_policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Principal = { Service = "ec2.amazonaws.com" }, Action = "sts:AssumeRole" }] })
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
resource "aws_iam_role_policy" "team_c_inline" {
|
|
24
|
+
name = "terralith-team-c-inline"
|
|
25
|
+
role = aws_iam_role.team_c.id
|
|
26
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:CreateLogStream"], Resource = "*" }] })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
resource "aws_iam_policy" "team_c" {
|
|
30
|
+
name = "terralith-team-c-policy"
|
|
31
|
+
policy = jsonencode({ Version = "2012-10-17", Statement = [{ Effect = "Allow", Action = ["logs:PutLogEvents"], Resource = "*" }] })
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
resource "aws_iam_role_policy_attachment" "team_c" {
|
|
35
|
+
role = aws_iam_role.team_c.name
|
|
36
|
+
policy_arn = aws_iam_policy.team_c.arn
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
resource "aws_cloudwatch_log_group" "team_c_0" {
|
|
40
|
+
name = "/terralith/team-c/svc-0"
|
|
41
|
+
retention_in_days = 7
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
resource "aws_cloudwatch_log_group" "team_c_1" {
|
|
45
|
+
name = "/terralith/team-c/svc-1"
|
|
46
|
+
retention_in_days = 7
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
resource "aws_cloudwatch_log_group" "team_c_2" {
|
|
50
|
+
name = "/terralith/team-c/svc-2"
|
|
51
|
+
retention_in_days = 7
|
|
52
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
terraform {
|
|
2
|
+
required_providers {
|
|
3
|
+
aws = {
|
|
4
|
+
source = "hashicorp/aws"
|
|
5
|
+
version = "= 6.59.0"
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
live {
|
|
9
|
+
estate = "terralith"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
provider "aws" {
|
|
14
|
+
region = "us-east-1"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# ---- network ----
|
|
18
|
+
resource "aws_vpc" "main" {
|
|
19
|
+
cidr_block = "10.42.0.0/16"
|
|
20
|
+
tags = { Name = "terralith-main" }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
resource "aws_subnet" "app" {
|
|
24
|
+
vpc_id = aws_vpc.main.id
|
|
25
|
+
cidr_block = "10.42.1.0/24"
|
|
26
|
+
tags = { Name = "terralith-app" }
|
|
27
|
+
}
|