Skip to content

Commit da14760

Browse files
authored
Update AWS cloud host credentials (#136)
* Add AWS Host Crendential support * Remove debug logging
1 parent 26099a5 commit da14760

8 files changed

Lines changed: 36 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
## UNRELEASED
22

3+
## 0.9.3 (June 13, 2023)
4+
35
NOTES:
46

7+
* Updated the `aws_cloud` resource to add support for using host IAM credentials when authenticating to the cloud. [#103](https://github.com/gomorpheus/terraform-provider-morpheus/issues/103)
58
* Updated the `api_option_list`, `manual_option_list`, and `rest_option_list` resources to better handle the difference in the payload returned from the API and the payload defined by Terraform. The payloads are now being compared after a trim operation has been performed on the payload passed by Terraform to address cases in which a HEREDOC is used that includes additional spacing for readability. [#128](https://github.com/gomorpheus/terraform-provider-morpheus/issues/128)
69
* Updated the `vsphere_cloud` resource to support importing existing VMware vSphere cloud integrations. [#129](https://github.com/gomorpheus/terraform-provider-morpheus/issues/129)
710
* Updated the logic for setting the state for the `provisioning_workflow` resource to properly account for the API returning the tasks in API versions prior to 5.5.x in an out of order sequence. This resulted in an inconsistent state and plans constantly indicating that there were changes to be made despite the real configuration not chaning. [#116](https://github.com/gomorpheus/terraform-provider-morpheus/issues/116)

docs/guides/getting_started.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ terraform {
2525
required_providers {
2626
morpheus = {
2727
source = "gomorpheus/morpheus"
28-
version = "0.9.2"
28+
version = "0.9.3"
2929
}
3030
}
3131
}
@@ -59,9 +59,9 @@ $ terraform init
5959
Initializing the backend...
6060
6161
Initializing provider plugins...
62-
- Finding morpheusdata.com/gomorpheus/morpheus versions matching "0.9.0"...
63-
- Installing morpheusdata.com/gomorpheus/morpheus v0.9.0...
64-
- Installed morpheusdata.com/gomorpheus/morpheus v0.9.0 (unauthenticated)
62+
- Finding morpheusdata.com/gomorpheus/morpheus versions matching "0.9.3"...
63+
- Installing morpheusdata.com/gomorpheus/morpheus v0.9.3...
64+
- Installed morpheusdata.com/gomorpheus/morpheus v0.9.3 (unauthenticated)
6565
6666
Terraform has created a lock file .terraform.lock.hcl to record the provider
6767
selections it made above. Include this file in your version control repository

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ terraform {
2525
required_providers {
2626
morpheus = {
2727
source = "gomorpheus/morpheus"
28-
version = "0.9.2"
28+
version = "0.9.3"
2929
}
3030
}
3131
}

docs/resources/aws_cloud.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ resource "morpheus_aws_cloud" "tf_example_aws_cloud" {
9494
- `tenant_id` (String) The id of the morpheus tenant the cloud is assigned to
9595
- `time_zone` (String) The time zone for the cloud
9696
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
97+
- `use_host_iam_credentials` (Boolean) Whether to use the IAM profile associated with the Morpheus server or not
9798
- `visibility` (String) Determines whether the cloud is visible in sub-tenants or not
9899
- `vpc` (String) The VPC ID for a specific VPC (all or the AWS VPC id (vpc-25e6dae))
99100

examples/guides/getting_started/provider.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
morpheus = {
44
source = "gomorpheus/morpheus"
5-
version = "0.9.2"
5+
version = "0.9.3"
66
}
77
}
88
}

examples/provider/provider.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
morpheus = {
44
source = "gomorpheus/morpheus"
5-
version = "0.9.2"
5+
version = "0.9.3"
66
}
77
}
88
}

morpheus/resource_aws_cloud.go

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,13 @@ func resourceAWSCloud() *schema.Resource {
117117
Optional: true,
118118
Computed: true,
119119
},
120-
/* AWAITING SDK SUPPORT
121120
"use_host_iam_credentials": {
122-
Description: "Whether to use the IAM profile associated with the Morpheus server or not",
123-
Type: schema.TypeBool,
124-
Optional: true,
125-
Computed: true,
121+
Description: "Whether to use the IAM profile associated with the Morpheus server or not",
122+
Type: schema.TypeBool,
123+
Optional: true,
124+
Computed: true,
125+
ConflictsWith: []string{"access_key", "secret_key"},
126126
},
127-
*/
128127
"inventory": {
129128
Type: schema.TypeString,
130129
Description: "Whether to import existing virtual machines (off, basic, full)",
@@ -224,6 +223,11 @@ func resourceAWSCloudCreate(ctx context.Context, d *schema.ResourceData, meta in
224223
config["secretKey"] = d.Get("secret_key").(string)
225224
}
226225

226+
if d.Get("use_host_iam_credentials").(bool) {
227+
config["useHostCredentials"] = "on"
228+
} else {
229+
config["useHostCredentials"] = "off"
230+
}
227231
config["stsAssumeRole"] = d.Get("role_arn").(string)
228232

229233
cloud["inventoryLevel"] = d.Get("inventory").(string)
@@ -273,7 +277,7 @@ func resourceAWSCloudCreate(ctx context.Context, d *schema.ResourceData, meta in
273277
cloudOutput := result.Cloud
274278

275279
stateConf := &resource.StateChangeConf{
276-
Pending: []string{"initializing"},
280+
Pending: []string{"initializing", "syncing"},
277281
Target: []string{"ok"},
278282
Refresh: func() (interface{}, string, error) {
279283
cloudDetails, err := client.GetCloud(cloudOutput.ID, &morpheus.Request{})
@@ -286,7 +290,7 @@ func resourceAWSCloudCreate(ctx context.Context, d *schema.ResourceData, meta in
286290
},
287291
Timeout: 1 * time.Hour,
288292
MinTimeout: 1 * time.Minute,
289-
Delay: 3 * time.Minute,
293+
Delay: 1 * time.Minute,
290294
PollInterval: 1 * time.Minute,
291295
}
292296

@@ -351,6 +355,11 @@ func resourceAWSCloudRead(ctx context.Context, d *schema.ResourceData, meta inte
351355
d.Set("credential_id", cloud.Credential.ID)
352356
d.Set("access_key", cloud.Config.AccessKey)
353357
d.Set("secret_key", cloud.Config.SecretKeyHash)
358+
if cloud.Config.UseHostCredentials == "" {
359+
d.Set("use_host_iam_credentials", false)
360+
} else {
361+
d.Set("use_host_iam_credentials", true)
362+
}
354363
d.Set("role_arn", cloud.Config.StsAssumeRole)
355364
d.Set("inventory", cloud.InventoryLevel)
356365
if cloud.Config.VPC == "" {
@@ -408,6 +417,11 @@ func resourceAWSCloudUpdate(ctx context.Context, d *schema.ResourceData, meta in
408417
config["secretKey"] = d.Get("secret_key").(string)
409418
}
410419

420+
if d.Get("use_host_iam_credentials").(bool) {
421+
config["useHostCredentials"] = "on"
422+
} else {
423+
config["useHostCredentials"] = "off"
424+
}
411425
config["stsAssumeRole"] = d.Get("role_arn").(string)
412426

413427
cloud["inventoryLevel"] = d.Get("inventory").(string)

templates/guides/getting_started.md.tmpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ $ terraform init
3737
Initializing the backend...
3838
3939
Initializing provider plugins...
40-
- Finding morpheusdata.com/gomorpheus/morpheus versions matching "0.9.0"...
41-
- Installing morpheusdata.com/gomorpheus/morpheus v0.9.0...
42-
- Installed morpheusdata.com/gomorpheus/morpheus v0.9.0 (unauthenticated)
40+
- Finding morpheusdata.com/gomorpheus/morpheus versions matching "0.9.3"...
41+
- Installing morpheusdata.com/gomorpheus/morpheus v0.9.3...
42+
- Installed morpheusdata.com/gomorpheus/morpheus v0.9.3 (unauthenticated)
4343
4444
Terraform has created a lock file .terraform.lock.hcl to record the provider
4545
selections it made above. Include this file in your version control repository

0 commit comments

Comments
 (0)