File tree Expand file tree Collapse file tree 11 files changed +248
-0
lines changed
Expand file tree Collapse file tree 11 files changed +248
-0
lines changed Original file line number Diff line number Diff line change 1+ 0.12.24
Original file line number Diff line number Diff line change 1+ # tf-performance-issue-test
2+
3+ This repository contains a Terraform workspace that exacerbates a performance
4+ issue.
5+
6+ The resources of the real workspace this is based upon have been replaced with
7+ ` null_resource ` resources that use a harmless ` local-exec ` provisioner command
8+ to allow for easier investigation of the graph-related performance issues
9+ separate from the provider/cloud interactions.
Original file line number Diff line number Diff line change 1+ locals {
2+ buckets = [
3+ " aaron" ,
4+ " amparo" ,
5+ " arturo" ,
6+ " bill" ,
7+ " billy" ,
8+ " cathy" ,
9+ " charlene" ,
10+ " david" ,
11+ " elsie" ,
12+ " erica" ,
13+ " ernestine" ,
14+ " fannie" ,
15+ " frederic" ,
16+ " gary" ,
17+ " george" ,
18+ " gerald" ,
19+ " homer" ,
20+ " jaimie" ,
21+ " jay" ,
22+ " john" ,
23+ " joseph" ,
24+ " lynn" ,
25+ " maria" ,
26+ " matthew" ,
27+ " patricia" ,
28+ " patrick" ,
29+ " paula" ,
30+ " peggy" ,
31+ " philip" ,
32+ " roberta" ,
33+ " thomas" ,
34+ ]
35+ }
36+
37+ # Stand-in for google_storage_bucket
38+ resource "null_resource" "bucket" {
39+ for_each = {
40+ for pair in setproduct (local. developers , local. buckets ) : " ${ pair [0 ]} __${ pair [1 ]} " => {
41+ developer = pair[0 ]
42+ bucket = pair[1 ]
43+ }
44+ }
45+
46+ provisioner "local-exec" {
47+ command = " echo ${ each . value . developer } ${ each . value . bucket } ${ random_id . bucket_name [each . key ]. hex } in project ${ null_resource. project [each . value . developer ]. id } "
48+ }
49+
50+ depends_on = [
51+ null_resource. project_service ,
52+ ]
53+ }
54+
55+ resource "random_id" "bucket_name" {
56+ for_each = {
57+ for pair in setproduct (local. developers , local. buckets ) : " ${ pair [0 ]} __${ pair [1 ]} " => {
58+ developer = pair[0 ]
59+ bucket = pair[1 ]
60+ }
61+ }
62+
63+ byte_length = 4
64+ prefix = " ${ each . value . bucket } -"
65+
66+ keepers = {
67+ developer = each.value.developer
68+ bucket = each.value.bucket
69+ }
70+ }
Original file line number Diff line number Diff line change 1+ locals {
2+ configurations = { for name in local . developers : name => jsonencode ({
3+ service_account = null_resource.service_account[name].id
4+ project = null_resource.project[name].id
5+ signing_key = null_resource.signing_key_version[name].id
6+ buckets = {
7+ for b in local . buckets : b => null_resource. bucket [" ${ name } __${ b } " ]. id
8+ }
9+ }) }
10+ }
11+
12+ # Stand-in for google_storage_bucket_object
13+ resource "null_resource" "configuration_file_output" {
14+ for_each = local. developers
15+
16+ provisioner "local-exec" {
17+ command = " echo ${ each . value } ${ sha256 (local. configurations [each . value ])} "
18+ }
19+ }
Original file line number Diff line number Diff line change 1+ /*
2+ data "google_iam_policy" "project_iam_policy" {
3+ for_each = local.developers
4+
5+ binding {
6+ role = "roles/owner"
7+
8+ members = [
9+ "serviceAccount:${null_resource.service_account[each.value].id}@bar.com",
10+ ]
11+ }
12+ }
13+ */
14+
15+ locals {
16+ # Stand-in for google_iam_policy
17+ project_iam_policy = { for n in local . developers : n => jsonencode ({
18+ foo = " serviceAccount:${ null_resource. service_account [n ]. id } @bar.com"
19+ }) }
20+ }
21+
22+ # Stand-in for google_project_iam_policy
23+ resource "null_resource" "project_iam_policy" {
24+ for_each = local. developers
25+
26+ provisioner "local-exec" {
27+ command = " echo ${ null_resource. project [each . value ]. id } ${ sha256 (local. project_iam_policy [each . value ])} "
28+ }
29+ }
Original file line number Diff line number Diff line change 1+ locals {
2+ developers = toset ([for username in local . developer_usernames : lower (username)])
3+
4+ developer_usernames = toset ([
5+ " andrea" ,
6+ " arthur" ,
7+ " bettyann" ,
8+ " bobby" ,
9+ " dean" ,
10+ " debra" ,
11+ " dennis" ,
12+ " edward" ,
13+ " elvin" ,
14+ " ernest" ,
15+ " frank" ,
16+ " iris" ,
17+ " irma" ,
18+ " jerry" ,
19+ " jo" ,
20+ " john" ,
21+ " lucas" ,
22+ " matthew" ,
23+ " michael" ,
24+ " patrice" ,
25+ " pauline" ,
26+ " pedro" ,
27+ " ricardo" ,
28+ " rose" ,
29+ " ruth" ,
30+ " sandra" ,
31+ " shane" ,
32+ " teddy" ,
33+ " wesley" ,
34+ ])
35+ }
Original file line number Diff line number Diff line change 1+ # Stand-in for google_project
2+ resource "null_resource" "project" {
3+ for_each = local. developers
4+
5+ provisioner "local-exec" {
6+ command = " echo ${ each . value } ${ random_id . project_id [each . value ]. hex } "
7+ }
8+ }
9+
10+ resource "random_id" "project_id" {
11+ for_each = local. developers
12+ prefix = " xy-dev-"
13+ byte_length = 4
14+ }
Original file line number Diff line number Diff line change 1+ locals {
2+ services = [
3+ " cloudkms.googleapis.com" ,
4+ " iam.googleapis.com" ,
5+ " iamcredentials.googleapis.com" ,
6+ " storage-api.googleapis.com" ,
7+ ]
8+ }
9+
10+ # Stand-in for google_project_service
11+ resource "null_resource" "project_service" {
12+ for_each = {
13+ for pair in setproduct (local. developers , local. services ) : " ${ pair [0 ]} __${ pair [1 ]} " => {
14+ developer = pair[0 ]
15+ service = pair[1 ]
16+ }
17+ }
18+
19+ provisioner "local-exec" {
20+ command = " echo ${ null_resource. project [each . value . developer ]. id } ${ each . value . service } "
21+ }
22+ }
Original file line number Diff line number Diff line change 1+ /*
2+ provider "google" {
3+ version = "~> 3.14"
4+ }
5+ */
6+
7+ provider "null" {
8+ version = " ~> 2.1"
9+ }
10+
11+ provider "random" {
12+ version = " ~> 2.2"
13+ }
Original file line number Diff line number Diff line change 1+ # Stand-in for google_service_account
2+ resource "null_resource" "service_account" {
3+ for_each = local. developers
4+
5+ provisioner "local-exec" {
6+ command = " echo ${ null_resource. project [each . value ]. id } "
7+ }
8+ }
You can’t perform that action at this time.
0 commit comments