Skip to content

Commit

Permalink
Fleet fix (#1)
Browse files Browse the repository at this point in the history
* image_name changed to image_arn
* image_builder -> iamge_arn -> ForceNew true
* go.sum added to .gitignore
* updated tf lib to 0.12.25

Co-authored-by: Konstantin Odnoralov <[email protected]>
  • Loading branch information
hostmit and Konstantin Odnoralov committed May 27, 2020
1 parent ec28de0 commit 4b8583f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ website/vendor
*.winfile eol=crlf
/.vs
node_modules


go.sum
24 changes: 13 additions & 11 deletions appstream/resource_fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ func resourceAppstreamFleet() *schema.Resource {
Type: schema.TypeString,
Optional: true,
},

"image_name": {
"image_arn": {
Type: schema.TypeString,
Required: true,
Required: true,
ForceNew: true,
},

"instance_type": {
Expand Down Expand Up @@ -185,10 +186,11 @@ func resourceAppstreamFleetCreate(d *schema.ResourceData, meta interface{}) erro
CreateFleetInputOpts.FleetType = aws.String(v.(string))
}

if v, ok := d.GetOk("image_name"); ok {
CreateFleetInputOpts.ImageName = aws.String(v.(string))
if v, ok := d.GetOk("image_arn"); ok {
CreateFleetInputOpts.ImageArn = aws.String(v.(string))
}


if v, ok := d.GetOk("instance_type"); ok {
CreateFleetInputOpts.InstanceType = aws.String(v.(string))
}
Expand Down Expand Up @@ -347,7 +349,7 @@ func resourceAppstreamFleetRead(d *schema.ResourceData, meta interface{}) error
d.Set("disconnect_timeout", v.DisconnectTimeoutInSeconds)
d.Set("enable_default_internet_access", v.EnableDefaultInternetAccess)
d.Set("fleet_type", v.FleetType)
d.Set("image_name", v.ImageName)
d.Set("image_arn", v.ImageArn)
d.Set("instance_type", v.InstanceType)
d.Set("max_user_duration", v.MaxUserDurationInSeconds)

Expand Down Expand Up @@ -402,7 +404,7 @@ func resourceAppstreamFleetUpdate(d *schema.ResourceData, meta interface{}) erro
}

if d.HasChange("description") {
d.SetPartial("description")
d.SetPartial("description")
log.Printf("[DEBUG] Modify Fleet")
description :=d.Get("description").(string)
UpdateFleetInputOpts.Description = aws.String(description)
Expand All @@ -422,11 +424,11 @@ func resourceAppstreamFleetUpdate(d *schema.ResourceData, meta interface{}) erro
UpdateFleetInputOpts.DisplayName = aws.String(display_name)
}

if d.HasChange("image_name") {
d.SetPartial("image_name")
if d.HasChange("image_arn") {
d.SetPartial("image_arn")
log.Printf("[DEBUG] Modify Fleet")
image_name :=d.Get("image_name").(string)
UpdateFleetInputOpts.ImageName = aws.String(image_name)
image_arn :=d.Get("image_arn").(string)
UpdateFleetInputOpts.ImageArn = aws.String(image_arn)
}

if d.HasChange("instance_type") {
Expand Down
9 changes: 5 additions & 4 deletions appstream/resource_image_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ func resourceAppstreamImageBuilder() *schema.Resource {
Optional: true,
},

"image_name": {
"image_arn": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},

"instance_type": {
Expand Down Expand Up @@ -136,8 +137,8 @@ func resourceAppstreamImageBuilderCreate(d *schema.ResourceData, meta interface{
CreateImageBuilderInputOpts.EnableDefaultInternetAccess = aws.Bool(v.(bool))
}

if v, ok := d.GetOk("image_name"); ok {
CreateImageBuilderInputOpts.ImageName = aws.String(v.(string))
if v, ok := d.GetOk("image_arn"); ok {
CreateImageBuilderInputOpts.ImageArn = aws.String(v.(string))
}

if v, ok := d.GetOk("instance_type"); ok {
Expand Down Expand Up @@ -226,7 +227,7 @@ func resourceAppstreamImageBuilderRead(d *schema.ResourceData, meta interface{})
d.Set("appstream_agent_version", v.AppstreamAgentVersion)
d.Set("enable_default_internet_access", v.EnableDefaultInternetAccess)
d.Set("instance_type", v.InstanceType)
d.Set("image_name", d.Get("image_name"))
d.Set("image_arn", d.Get("image_arn"))
d.Set("state", v.State)
if v.VpcConfig != nil {
vpc_attr := map[string]interface{}{}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.14
require (
github.com/aws/aws-sdk-go v1.30.19
github.com/hashicorp/aws-sdk-go-base v0.4.0
github.com/hashicorp/terraform v0.12.24
github.com/hashicorp/terraform v0.12.25
github.com/hashicorp/terraform-plugin-sdk v1.11.0
github.com/mitchellh/go-homedir v1.1.0
)

0 comments on commit 4b8583f

Please sign in to comment.