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

r/aws_storagegateway_smb_file_share: Add file_share_name argument #16008

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 15 additions & 1 deletion aws/resource_aws_storagegateway_smb_file_share.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ func resourceAwsStorageGatewaySmbFileShare() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"file_share_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"gateway_arn": {
Type: schema.TypeString,
Required: true,
Expand Down Expand Up @@ -191,6 +196,10 @@ func resourceAwsStorageGatewaySmbFileShareCreate(d *schema.ResourceData, meta in
input.AuditDestinationARN = aws.String(v.(string))
}

if v, ok := d.GetOk("file_share_name"); ok {
input.FileShareName = aws.String(v.(string))
}

if v, ok := d.GetOk("smb_acl_enabled"); ok {
input.SMBACLEnabled = aws.Bool(v.(bool))
}
Expand Down Expand Up @@ -255,6 +264,7 @@ func resourceAwsStorageGatewaySmbFileShareRead(d *schema.ResourceData, meta inte
d.Set("authentication", fileshare.Authentication)
d.Set("default_storage_class", fileshare.DefaultStorageClass)
d.Set("fileshare_id", fileshare.FileShareId)
d.Set("file_share_name", fileshare.FileShareName)
d.Set("gateway_arn", fileshare.GatewayARN)
d.Set("guess_mime_type_enabled", fileshare.GuessMIMETypeEnabled)
d.Set("case_sensitivity", fileshare.CaseSensitivity)
Expand Down Expand Up @@ -306,7 +316,7 @@ func resourceAwsStorageGatewaySmbFileShareUpdate(d *schema.ResourceData, meta in
if d.HasChanges("admin_user_list", "default_storage_class", "guess_mime_type_enabled", "invalid_user_list",
"kms_encrypted", "object_acl", "read_only", "requester_pays", "requester_pays",
"valid_user_list", "kms_key_arn", "audit_destination_arn", "smb_acl_enabled", "cache_attributes",
"case_sensitivity") {
"case_sensitivity", "file_share_name") {
input := &storagegateway.UpdateSMBFileShareInput{
DefaultStorageClass: aws.String(d.Get("default_storage_class").(string)),
FileShareARN: aws.String(d.Id()),
Expand All @@ -330,6 +340,10 @@ func resourceAwsStorageGatewaySmbFileShareUpdate(d *schema.ResourceData, meta in
input.AuditDestinationARN = aws.String(v.(string))
}

if v, ok := d.GetOk("file_share_name"); ok {
input.FileShareName = aws.String(v.(string))
}

if v, ok := d.GetOk("cache_attributes"); ok {
input.CacheAttributes = expandStorageGatewayNfsFileShareCacheAttributes(v.([]interface{}))
}
Expand Down
48 changes: 48 additions & 0 deletions aws/resource_aws_storagegateway_smb_file_share_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TestAccAWSStorageGatewaySmbFileShare_Authentication_ActiveDirectory(t *test
resource.TestCheckResourceAttr(resourceName, "authentication", "ActiveDirectory"),
resource.TestCheckResourceAttr(resourceName, "default_storage_class", "S3_STANDARD"),
resource.TestMatchResourceAttr(resourceName, "fileshare_id", regexp.MustCompile(`^share-`)),
resource.TestMatchResourceAttr(resourceName, "file_share_name", regexp.MustCompile(`^tf-acc-test-`)),
resource.TestCheckResourceAttrPair(resourceName, "gateway_arn", gatewayResourceName, "arn"),
resource.TestCheckResourceAttr(resourceName, "guess_mime_type_enabled", "true"),
resource.TestCheckResourceAttr(resourceName, "invalid_user_list.#", "0"),
Expand Down Expand Up @@ -81,6 +82,7 @@ func TestAccAWSStorageGatewaySmbFileShare_Authentication_GuestAccess(t *testing.
resource.TestCheckResourceAttr(resourceName, "case_sensitivity", "ClientSpecified"),
resource.TestCheckResourceAttr(resourceName, "default_storage_class", "S3_STANDARD"),
resource.TestMatchResourceAttr(resourceName, "fileshare_id", regexp.MustCompile(`^share-`)),
resource.TestMatchResourceAttr(resourceName, "file_share_name", regexp.MustCompile(`^tf-acc-test-`)),
resource.TestCheckResourceAttrPair(resourceName, "gateway_arn", gatewayResourceName, "arn"),
resource.TestCheckResourceAttr(resourceName, "guess_mime_type_enabled", "true"),
resource.TestCheckResourceAttr(resourceName, "invalid_user_list.#", "0"),
Expand Down Expand Up @@ -136,6 +138,39 @@ func TestAccAWSStorageGatewaySmbFileShare_DefaultStorageClass(t *testing.T) {
})
}

func TestAccAWSStorageGatewaySmbFileShare_FileShareName(t *testing.T) {
var smbFileShare storagegateway.SMBFileShareInfo
rName := acctest.RandomWithPrefix("tf-acc-test")
resourceName := "aws_storagegateway_smb_file_share.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSStorageGatewaySmbFileShareDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSStorageGatewaySmbFileShareConfig_FileShareName(rName, "foo_share"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSStorageGatewaySmbFileShareExists(resourceName, &smbFileShare),
resource.TestCheckResourceAttr(resourceName, "file_share_name", "foo_share"),
),
},
{
Config: testAccAWSStorageGatewaySmbFileShareConfig_FileShareName(rName, "bar_share"),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSStorageGatewaySmbFileShareExists(resourceName, &smbFileShare),
resource.TestCheckResourceAttr(resourceName, "file_share_name", "bar_share"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAWSStorageGatewaySmbFileShare_Tags(t *testing.T) {
var smbFileShare storagegateway.SMBFileShareInfo
rName := acctest.RandomWithPrefix("tf-acc-test")
Expand Down Expand Up @@ -881,6 +916,19 @@ resource "aws_storagegateway_smb_file_share" "test" {
`, defaultStorageClass)
}

func testAccAWSStorageGatewaySmbFileShareConfig_FileShareName(rName, fileShareName string) string {
return testAccAWSStorageGateway_SmbFileShare_GuestAccessBase(rName) + fmt.Sprintf(`
resource "aws_storagegateway_smb_file_share" "test" {
# Use GuestAccess to simplify testing
authentication = "GuestAccess"
file_share_name = %q
gateway_arn = aws_storagegateway_gateway.test.arn
location_arn = aws_s3_bucket.test.arn
role_arn = aws_iam_role.test.arn
}
`, fileShareName)
}

func testAccAWSStorageGatewaySmbFileShareConfig_GuessMIMETypeEnabled(rName string, guessMimeTypeEnabled bool) string {
return testAccAWSStorageGateway_SmbFileShare_GuestAccessBase(rName) + fmt.Sprintf(`
resource "aws_storagegateway_smb_file_share" "test" {
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/storagegateway_smb_file_share.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ The following arguments are supported:
* `authentication` - (Optional) The authentication method that users use to access the file share. Defaults to `ActiveDirectory`. Valid values: `ActiveDirectory`, `GuestAccess`.
* `audit_destination_arn` - (Optional) The Amazon Resource Name (ARN) of the CloudWatch Log Group used for the audit logs.
* `default_storage_class` - (Optional) The default storage class for objects put into an Amazon S3 bucket by the file gateway. Defaults to `S3_STANDARD`. Valid values: `S3_STANDARD`, `S3_STANDARD_IA`, `S3_ONEZONE_IA`.
* `file_share_name` - (Optional) The name of the file share. Must be set if an S3 prefix name is set in `location_arn`.
* `guess_mime_type_enabled` - (Optional) Boolean value that enables guessing of the MIME type for uploaded objects based on file extensions. Defaults to `true`.
* `invalid_user_list` - (Optional) A list of users in the Active Directory that are not allowed to access the file share. Only valid if `authentication` is set to `ActiveDirectory`.
* `kms_encrypted` - (Optional) Boolean value if `true` to use Amazon S3 server side encryption with your own AWS KMS key, or `false` to use a key managed by Amazon S3. Defaults to `false`.
Expand Down