-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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/storagegatway_smb_file_share - add support for smb acl + audit #13572
Merged
bflad
merged 5 commits into
hashicorp:master
from
DrFaust92:r/storagegateway_smb_file_share-arguments
Aug 20, 2020
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -462,6 +462,81 @@ func TestAccAWSStorageGatewaySmbFileShare_ValidUserList(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccAWSStorageGatewaySmbFileShare_smb_acl(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: testAccAWSStorageGatewaySmbFileShareSMBACLConfig(rName, true), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSStorageGatewaySmbFileShareExists(resourceName, &smbFileShare), | ||
resource.TestCheckResourceAttr(resourceName, "smb_acl_enabled", "true"), | ||
), | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
{ | ||
Config: testAccAWSStorageGatewaySmbFileShareSMBACLConfig(rName, false), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSStorageGatewaySmbFileShareExists(resourceName, &smbFileShare), | ||
resource.TestCheckResourceAttr(resourceName, "smb_acl_enabled", "false"), | ||
), | ||
}, | ||
{ | ||
Config: testAccAWSStorageGatewaySmbFileShareSMBACLConfig(rName, true), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSStorageGatewaySmbFileShareExists(resourceName, &smbFileShare), | ||
resource.TestCheckResourceAttr(resourceName, "smb_acl_enabled", "true"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccAWSStorageGatewaySmbFileShare_audit(t *testing.T) { | ||
var smbFileShare storagegateway.SMBFileShareInfo | ||
rName := acctest.RandomWithPrefix("tf-acc-test") | ||
resourceName := "aws_storagegateway_smb_file_share.test" | ||
logResourceName := "aws_cloudwatch_log_group.test" | ||
logResourceNameSecond := "aws_cloudwatch_log_group.test2" | ||
|
||
resource.ParallelTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckAWSStorageGatewaySmbFileShareDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccAWSStorageGatewaySmbFileShareAuditDestinationConfig(rName), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSStorageGatewaySmbFileShareExists(resourceName, &smbFileShare), | ||
resource.TestCheckResourceAttrPair(resourceName, "audit_destination_arn", logResourceName, "arn"), | ||
), | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
{ | ||
Config: testAccAWSStorageGatewaySmbFileShareAuditDestinationUpdatedConfig(rName), | ||
Check: resource.ComposeTestCheckFunc( | ||
testAccCheckAWSStorageGatewaySmbFileShareExists(resourceName, &smbFileShare), | ||
resource.TestCheckResourceAttrPair(resourceName, "audit_destination_arn", logResourceNameSecond, "arn"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccCheckAWSStorageGatewaySmbFileShareDestroy(s *terraform.State) error { | ||
conn := testAccProvider.Meta().(*AWSClient).storagegatewayconn | ||
|
||
|
@@ -844,3 +919,53 @@ resource "aws_storagegateway_smb_file_share" "test" { | |
} | ||
`, tagKey1, tagValue1, tagKey2, tagValue2) | ||
} | ||
|
||
func testAccAWSStorageGatewaySmbFileShareSMBACLConfig(rName string, enabled bool) string { | ||
return testAccAWSStorageGateway_SmbFileShare_ActiveDirectoryBase(rName) + fmt.Sprintf(` | ||
resource "aws_storagegateway_smb_file_share" "test" { | ||
authentication = "ActiveDirectory" | ||
gateway_arn = "${aws_storagegateway_gateway.test.arn}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔜 0.11 syntax CI failures 😂 Not 🔜 enough. (I tease! I know you have a huge backlog of open things that we need to get through) |
||
location_arn = "${aws_s3_bucket.test.arn}" | ||
role_arn = "${aws_iam_role.test.arn}" | ||
smb_acl_enabled = %[1]t | ||
} | ||
`, enabled) | ||
} | ||
|
||
func testAccAWSStorageGatewaySmbFileShareAuditDestinationConfig(rName string) string { | ||
return testAccAWSStorageGateway_SmbFileShare_GuestAccessBase(rName) + fmt.Sprintf(` | ||
resource "aws_cloudwatch_log_group" "test" { | ||
name = %[1]q | ||
} | ||
|
||
resource "aws_storagegateway_smb_file_share" "test" { | ||
# Use GuestAccess to simplify testing | ||
authentication = "GuestAccess" | ||
gateway_arn = "${aws_storagegateway_gateway.test.arn}" | ||
location_arn = "${aws_s3_bucket.test.arn}" | ||
role_arn = "${aws_iam_role.test.arn}" | ||
audit_destination_arn = "${aws_cloudwatch_log_group.test.arn}" | ||
} | ||
`, rName) | ||
} | ||
|
||
func testAccAWSStorageGatewaySmbFileShareAuditDestinationUpdatedConfig(rName string) string { | ||
return testAccAWSStorageGateway_SmbFileShare_GuestAccessBase(rName) + fmt.Sprintf(` | ||
resource "aws_cloudwatch_log_group" "test" { | ||
name = %[1]q | ||
} | ||
|
||
resource "aws_cloudwatch_log_group" "test2" { | ||
name = "%[1]s-updated" | ||
} | ||
|
||
resource "aws_storagegateway_smb_file_share" "test" { | ||
# Use GuestAccess to simplify testing | ||
authentication = "GuestAccess" | ||
gateway_arn = "${aws_storagegateway_gateway.test.arn}" | ||
location_arn = "${aws_s3_bucket.test.arn}" | ||
role_arn = "${aws_iam_role.test.arn}" | ||
audit_destination_arn = "${aws_cloudwatch_log_group.test2.arn}" | ||
} | ||
`, rName) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: The zero value check is extraneous since it is using
GetOk()
. We should setup tfproviderlint for this. 😅