Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add maximum_length to the user_settings set within aws_appstream_stack #39078

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions internal/service/appstream/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/hashicorp/terraform-provider-aws/internal/errs"
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
"github.com/hashicorp/terraform-provider-aws/internal/flex"
"github.com/hashicorp/terraform-provider-aws/internal/sdkv2/types/nullable"
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
"github.com/hashicorp/terraform-provider-aws/internal/tfresource"
"github.com/hashicorp/terraform-provider-aws/internal/verify"
Expand Down Expand Up @@ -195,6 +196,11 @@ func ResourceStack() *schema.Resource {
Required: true,
ValidateDiagFunc: enum.Validate[awstypes.Action](),
},
"maximum_length": {
Type: nullable.TypeNullableInt,
Optional: true,
ValidateFunc: nullable.ValidateTypeStringNullableIntBetween(1, 20971520),
},
"permission": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -354,7 +360,7 @@ func resourceStackRead(ctx context.Context, d *schema.ResourceData, meta interfa
if err = d.Set("storage_connectors", flattenStorageConnectors(stack.StorageConnectors)); err != nil {
return sdkdiag.AppendErrorf(diags, "setting storage_connectors: %s", err)
}
if err = d.Set("streaming_experience_settings", flattenStreaminExperienceSettings(stack.StreamingExperienceSettings)); err != nil {
if err = d.Set("streaming_experience_settings", flattenStreamingExperienceSettings(stack.StreamingExperienceSettings)); err != nil {
return sdkdiag.AppendErrorf(diags, "setting streaming_experience_settings: %s", err)
}
if err = d.Set("user_settings", flattenUserSettings(stack.UserSettings)); err != nil {
Expand Down Expand Up @@ -589,7 +595,7 @@ func expandStreamingExperienceSettings(tfList []interface{}) *awstypes.Streaming
return apiObject
}

func flattenStreaminExperienceSetting(apiObject *awstypes.StreamingExperienceSettings) map[string]interface{} {
func flattenStreamingExperienceSetting(apiObject *awstypes.StreamingExperienceSettings) map[string]interface{} {
if apiObject == nil {
return nil
}
Expand All @@ -599,14 +605,14 @@ func flattenStreaminExperienceSetting(apiObject *awstypes.StreamingExperienceSet
}
}

func flattenStreaminExperienceSettings(apiObject *awstypes.StreamingExperienceSettings) []interface{} {
func flattenStreamingExperienceSettings(apiObject *awstypes.StreamingExperienceSettings) []interface{} {
if apiObject == nil {
return nil
}

var tfList []interface{}

tfList = append(tfList, flattenStreaminExperienceSetting(apiObject))
tfList = append(tfList, flattenStreamingExperienceSetting(apiObject))

return tfList
}
Expand Down Expand Up @@ -683,6 +689,12 @@ func expandUserSetting(tfMap map[string]interface{}) awstypes.UserSetting {
Permission: awstypes.Permission(tfMap["permission"].(string)),
}

if v, ok := tfMap["maximum_length"].(string); ok {
if v, null, _ := nullable.Int(v).ValueInt32(); !null {
apiObject.MaximumLength = aws.Int32(v)
}
}

return apiObject
}

Expand Down Expand Up @@ -712,6 +724,10 @@ func flattenUserSetting(apiObject awstypes.UserSetting) map[string]interface{} {
tfMap[names.AttrAction] = string(apiObject.Action)
tfMap["permission"] = string(apiObject.Permission)

if v := apiObject.MaximumLength; v != nil {
tfMap["maximum_length"] = flex.Int32ToStringValue(v)
}

return tfMap
}

Expand Down
6 changes: 4 additions & 2 deletions internal/service/appstream/stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func TestAccAppStreamStack_complete(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "redirect_url", ""),
resource.TestCheckResourceAttr(resourceName, "storage_connectors.#", acctest.Ct1),
resource.TestCheckResourceAttr(resourceName, "user_settings.#", "7"),
resource.TestCheckResourceAttr(resourceName, "user_settings.1.maximum_length", "32"),
resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.Ct0),
resource.TestCheckResourceAttr(resourceName, acctest.CtTagsAllPercent, acctest.Ct0),
),
Expand Down Expand Up @@ -427,8 +428,9 @@ resource "aws_appstream_stack" "test" {
permission = "ENABLED"
}
user_settings {
action = "CLIPBOARD_COPY_TO_LOCAL_DEVICE"
permission = "ENABLED"
action = "CLIPBOARD_COPY_TO_LOCAL_DEVICE"
maximum_length = 32
permission = "ENABLED"
}
user_settings {
action = "DOMAIN_PASSWORD_SIGNIN"
Expand Down
11 changes: 7 additions & 4 deletions website/docs/r/appstream_stack.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ resource "aws_appstream_stack" "example" {
}

user_settings {
action = "CLIPBOARD_COPY_FROM_LOCAL_DEVICE"
permission = "ENABLED"
action = "CLIPBOARD_COPY_FROM_LOCAL_DEVICE"
maximum_length = 256
permission = "ENABLED"
}
user_settings {
action = "CLIPBOARD_COPY_TO_LOCAL_DEVICE"
permission = "ENABLED"
action = "CLIPBOARD_COPY_TO_LOCAL_DEVICE"
maximum_length = 256
permission = "ENABLED"
}
user_settings {
action = "DOMAIN_PASSWORD_SIGNIN"
Expand Down Expand Up @@ -115,6 +117,7 @@ The following arguments are optional:
Valid values are `CLIPBOARD_COPY_FROM_LOCAL_DEVICE`, `CLIPBOARD_COPY_TO_LOCAL_DEVICE`, `FILE_UPLOAD`, `FILE_DOWNLOAD`, `PRINTING_TO_LOCAL_DEVICE`, `DOMAIN_PASSWORD_SIGNIN`, or `DOMAIN_SMART_CARD_SIGNIN`.
* `permission` - (Required) Whether the action is enabled or disabled.
Valid values are `ENABLED` or `DISABLED`.
* `maximum_length` - (Optional) Specifies the number of characters that can be copied by end users from the local device to the remote session, and to the local device from the remote session. The value can be between 1 and 20,971,520 (20 MB)

### `streaming_experience_settings`

Expand Down
Loading