terraform: align infrastructure module attributes (#2703)

* all vars have snail_case

* make iam schema consistent

* infrastructure schema

* terraform: update AWS infrastructure module

* fix ci

* terraform: update AWS infrastructure module

* terraform: update AWS IAM module

* terraform: update Azure Infrastructure module inputs

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* terraform: update Azure IAM module

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* terraform: update GCP infrastructure module

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* terraform: update GCP IAM module

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* terraform: update OpenStack Infrastructure module

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* terraform: update QEMU Infrastructure module

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* terraform-module: fix input name

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* terraform: tidy

* cli: ignore whitespace in Terraform variable tests

* terraform-module: fix AWS output names

* terraform-module: fix output references

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>

* terraform: rename `api_server_cert_sans`

* Update terraform/infrastructure/aws/modules/public_private_subnet/variables.tf

Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com>

* fix self-managed

* terraform: revert AWS modules output file renaming

* terraform: remove duplicate varable declaration

* terraform: rename Azure location field

* ci: adjust output name in self-managed e2e test

* e2e: continuously print output in upgrade test

* e2e: write to output variables

* cli: migrate IAM variable names

* cli: make `location` field optional

---------

Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>
Co-authored-by: Moritz Sanft <58110325+msanft@users.noreply.github.com>
Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com>
This commit is contained in:
Adrian Stobbe 2023-12-15 10:36:58 +01:00 committed by GitHub
parent 6f6f28b8cc
commit 9667dfff58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
76 changed files with 745 additions and 767 deletions

View file

@ -122,7 +122,7 @@ func TestPrepareIAM(t *testing.T) {
ServiceAccountID: "const-test-case",
}
azureVars := &AzureIAMVariables{
Region: "westus",
Location: "westus",
ResourceGroup: "constell-test-rg",
}
awsVars := &AWSIAMVariables{
@ -218,7 +218,7 @@ func TestCreateCluster(t *testing.T) {
"in_cluster_endpoint": {
Value: "192.0.2.101",
},
"initSecret": {
"init_secret": {
Value: "initSecret",
},
"uid": {
@ -230,7 +230,7 @@ func TestCreateCluster(t *testing.T) {
"name": {
Value: "constell-12345abc",
},
"ip_cidr_nodes": {
"ip_cidr_node": {
Value: "192.0.2.103/32",
},
},
@ -248,13 +248,13 @@ func TestCreateCluster(t *testing.T) {
"in_cluster_endpoint": {
Value: "192.0.2.101",
},
"initSecret": {
"init_secret": {
Value: "initSecret",
},
"uid": {
Value: "12345abc",
},
"attestationURL": {
"attestation_url": {
Value: "https://12345.neu.attest.azure.net",
},
"api_server_cert_sans": {
@ -278,7 +278,7 @@ func TestCreateCluster(t *testing.T) {
"name": {
Value: "constell-12345abc",
},
"ip_cidr_nodes": {
"ip_cidr_node": {
Value: "192.0.2.103/32",
},
},
@ -460,7 +460,7 @@ func TestCreateCluster(t *testing.T) {
tf: &stubTerraform{
showState: &tfjson.State{
Values: &tfjson.StateValues{
Outputs: map[string]*tfjson.StateOutput{"attestationURL": {Value: 42}},
Outputs: map[string]*tfjson.StateOutput{"attestation_url": {Value: 42}},
},
},
},
@ -506,7 +506,7 @@ func TestCreateIAM(t *testing.T) {
workingState := tfjson.State{
Values: &tfjson.StateValues{
Outputs: map[string]*tfjson.StateOutput{
"sa_key": {
"service_account_key": {
Value: "12345678_abcdefg",
},
"subscription_id": {
@ -524,11 +524,11 @@ func TestCreateIAM(t *testing.T) {
"application_client_secret_value": {
Value: "test_application_client_secret_value",
},
"control_plane_instance_profile": {
Value: "test_control_plane_instance_profile",
"iam_instance_profile_name_control_plane": {
Value: "test_iam_instance_profile_name_control_plane",
},
"worker_nodes_instance_profile": {
Value: "test_worker_nodes_instance_profile",
"iam_instance_profile_name_worker_nodes": {
Value: "test_iam_instance_profile_name_worker_nodes",
},
},
},
@ -542,7 +542,7 @@ func TestCreateIAM(t *testing.T) {
ServiceAccountID: "const-test-case",
}
azureVars := &AzureIAMVariables{
Region: "westus",
Location: "westus",
ResourceGroup: "constell-test-rg",
}
awsVars := &AWSIAMVariables{
@ -607,7 +607,7 @@ func TestCreateIAM(t *testing.T) {
fs: afero.NewMemMapFs(),
wantErr: true,
},
"gcp no sa_key": {
"gcp no service_account_key": {
pathBase: path.Join(constants.TerraformEmbeddedDir, "iam"),
provider: cloudprovider.GCP,
vars: gcpVars,
@ -621,14 +621,14 @@ func TestCreateIAM(t *testing.T) {
fs: afero.NewMemMapFs(),
wantErr: true,
},
"gcp sa_key has wrong type": {
"gcp service_account_key has wrong type": {
pathBase: path.Join(constants.TerraformEmbeddedDir, "iam"),
provider: cloudprovider.GCP,
vars: gcpVars,
tf: &stubTerraform{
showState: &tfjson.State{
Values: &tfjson.StateValues{
Outputs: map[string]*tfjson.StateOutput{"sa_key": {Value: 42}},
Outputs: map[string]*tfjson.StateOutput{"service_account_key": {Value: 42}},
},
},
},
@ -706,8 +706,8 @@ func TestCreateIAM(t *testing.T) {
tf: &stubTerraform{showState: newTestState()},
fs: afero.NewMemMapFs(),
want: IAMOutput{AWS: AWSIAMOutput{
ControlPlaneInstanceProfile: "test_control_plane_instance_profile",
WorkerNodeInstanceProfile: "test_worker_nodes_instance_profile",
ControlPlaneInstanceProfile: "test_iam_instance_profile_name_control_plane",
WorkerNodeInstanceProfile: "test_iam_instance_profile_name_worker_nodes",
}},
},
"aws init fails": {
@ -734,7 +734,7 @@ func TestCreateIAM(t *testing.T) {
fs: afero.NewMemMapFs(),
wantErr: true,
},
"aws no control_plane_instance_profile": {
"aws no iam_instance_profile_name_control_plane": {
pathBase: path.Join(constants.TerraformEmbeddedDir, "iam"),
provider: cloudprovider.AWS,
vars: awsVars,
@ -748,14 +748,14 @@ func TestCreateIAM(t *testing.T) {
fs: afero.NewMemMapFs(),
wantErr: true,
},
"azure control_plane_instance_profile has wrong type": {
"azure iam_instance_profile_name_control_plane has wrong type": {
pathBase: path.Join(constants.TerraformEmbeddedDir, "iam"),
provider: cloudprovider.AWS,
vars: awsVars,
tf: &stubTerraform{
showState: &tfjson.State{
Values: &tfjson.StateValues{
Outputs: map[string]*tfjson.StateOutput{"control_plane_instance_profile": {Value: 42}},
Outputs: map[string]*tfjson.StateOutput{"iam_instance_profile_name_control_plane": {Value: 42}},
},
},
},
@ -1129,7 +1129,7 @@ func TestShowIAM(t *testing.T) {
"GCP success": {
tf: &stubTerraform{
showState: getTfjsonState(map[string]any{
"sa_key": "key",
"service_account_key": "key",
}),
},
csp: cloudprovider.GCP,
@ -1137,7 +1137,7 @@ func TestShowIAM(t *testing.T) {
"GCP wrong data type": {
tf: &stubTerraform{
showState: getTfjsonState(map[string]any{
"sa_key": map[string]any{},
"service_account_key": map[string]any{},
}),
},
csp: cloudprovider.GCP,
@ -1226,45 +1226,45 @@ func TestShowIAM(t *testing.T) {
"AWS success": {
tf: &stubTerraform{
showState: getTfjsonState(map[string]any{
"control_plane_instance_profile": "profile",
"worker_nodes_instance_profile": "profile",
"iam_instance_profile_name_control_plane": "profile",
"iam_instance_profile_name_worker_nodes": "profile",
}),
},
csp: cloudprovider.AWS,
},
"AWS wrong data type control_plane_instance_profile": {
"AWS wrong data type iam_instance_profile_name_control_plane": {
tf: &stubTerraform{
showState: getTfjsonState(map[string]any{
"control_plane_instance_profile": map[string]any{},
"worker_nodes_instance_profile": "profile",
"iam_instance_profile_name_control_plane": map[string]any{},
"iam_instance_profile_name_worker_nodes": "profile",
}),
},
csp: cloudprovider.AWS,
wantErr: true,
},
"AWS wrong data type worker_nodes_instance_profile": {
"AWS wrong data type iam_instance_profile_name_worker_nodes": {
tf: &stubTerraform{
showState: getTfjsonState(map[string]any{
"control_plane_instance_profile": "profile",
"worker_nodes_instance_profile": map[string]any{},
"iam_instance_profile_name_control_plane": "profile",
"iam_instance_profile_name_worker_nodes": map[string]any{},
}),
},
csp: cloudprovider.AWS,
wantErr: true,
},
"AWS missing control_plane_instance_profile": {
"AWS missing iam_instance_profile_name_control_plane": {
tf: &stubTerraform{
showState: getTfjsonState(map[string]any{
"worker_nodes_instance_profile": "profile",
"iam_instance_profile_name_worker_nodes": "profile",
}),
},
csp: cloudprovider.AWS,
wantErr: true,
},
"AWS missing worker_nodes_instance_profile": {
"AWS missing iam_instance_profile_name_worker_nodes": {
tf: &stubTerraform{
showState: getTfjsonState(map[string]any{
"control_plane_instance_profile": "profile",
"iam_instance_profile_name_control_plane": "profile",
}),
},
csp: cloudprovider.AWS,