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

Amazon S3 Access Grants #34564

Merged
merged 108 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 101 commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
1a64210
Use S3 Access Grants Beta1.3 SDK.
ewbankkit Oct 20, 2023
745043d
Add 'withMeta.RegionalARN'.
ewbankkit Sep 5, 2023
613bc77
Add 'enum.FrameworkDefault'.
ewbankkit Oct 17, 2023
990f6f3
framework/types: Add 'ToPtr' and 'ToSlice' methods.
ewbankkit Oct 17, 2023
4ba503d
Add 'validators.AWSAccountID'.
ewbankkit Oct 20, 2023
a7fbfe6
r/aws_s3control_access_grants_instance: Initial skeleton.
ewbankkit Oct 20, 2023
e48ee66
r/aws_s3control_access_grants_instance: Continue with implementation.
ewbankkit Oct 23, 2023
388885e
Add CHANGELOG entry.
ewbankkit Oct 23, 2023
05da8f2
r/aws_s3control_access_grants_instance: Add documentation.
ewbankkit Oct 23, 2023
c2c15d0
s3control: Rename tagging functions for S3Tags.
ewbankkit Oct 23, 2023
b500a11
s3control: Generate tagging functions for Tags.
ewbankkit Oct 23, 2023
9a7cf57
r/aws_s3control_access_grants_instance: Can't use transparent tagging…
ewbankkit Oct 23, 2023
3bd49e9
r/aws_s3control_access_grants_instance: Add tagging functionality.
ewbankkit Oct 24, 2023
987f59b
r/aws_s3control_access_grants_instance: Initial acceptance test.
ewbankkit Oct 24, 2023
6dcf00b
Acceptance test output:
ewbankkit Oct 24, 2023
987c302
r/aws_s3control_access_grants_instance: Additional acceptance test.
ewbankkit Oct 24, 2023
9945e1f
Comment out tagging tests for now.
ewbankkit Oct 24, 2023
a0aad95
Tweak error message.
ewbankkit Oct 24, 2023
bba8588
Acceptance test output:
ewbankkit Oct 24, 2023
11b9d58
r/aws_s3control_access_grants_instance: Tweak Delete.
ewbankkit Oct 24, 2023
34453fc
Add 'StringValuable' assetions for custom string types.
ewbankkit Oct 24, 2023
9170bbe
Remove 'flex.ARNStringFromFramework' -- 'flex.StringFromFramework' no…
ewbankkit Oct 24, 2023
d0fdeb9
r/aws_s3control_access_grants_instance: Tweak resource model.
ewbankkit Oct 24, 2023
6fc3b70
Acceptance test output:
ewbankkit Oct 24, 2023
9088bb1
d/aws_globalaccelerator_accelerator: Use 'flex.flex.StringToFramework…
ewbankkit Oct 24, 2023
7b76b1a
Document 'flex.StringToFrameworkARN'.
ewbankkit Oct 24, 2023
d39fd05
framework/flex: Use 'Valuable' interfaces.
ewbankkit Oct 24, 2023
8b33806
r/aws_s3control_access_grants_location: Initial implementation.
ewbankkit Oct 24, 2023
3951300
r/aws_s3control_access_grants_location: Add documentation.
ewbankkit Oct 24, 2023
1359a97
r/aws_s3control_access_grants_location: Add acceptance tests.
ewbankkit Oct 24, 2023
fc6e0c3
Avoid duplicate calls to STS in 'ConfigureProvider'.
ewbankkit Oct 13, 2023
e2b64a9
provider.New: Use 'errors.Join'.
ewbankkit Oct 13, 2023
b06e64f
Add 'AWSClient.RegisterLogger()'.
ewbankkit Oct 13, 2023
ce2cd1d
provider: Use 'AWSClient.RegisterLogger()'.
ewbankkit Oct 13, 2023
1eed06b
fwprovider: Use 'errors.Join'.
ewbankkit Oct 13, 2023
3bad085
fwprovider: Use 'AWSClient.RegisterLogger()'.
ewbankkit Oct 13, 2023
0ef838e
fwprovider/wrappedDataSource: Ensure that 'meta' is initialized.
ewbankkit Oct 13, 2023
3950c3f
Add 'tfresource.RetryWhenHTTPStatusCodeEquals'.
ewbankkit Oct 24, 2023
6bf632c
r/aws_s3control_access_grants_location: Retry Create for IAM eventual…
ewbankkit Oct 24, 2023
7d0c9eb
Acceptance test output:
ewbankkit Oct 24, 2023
883cf27
r/aws_s3control_access_grants_location: Update IAM role.
ewbankkit Oct 24, 2023
3c5be4f
r/aws_s3control_access_grants_location: Additional acceptance tests.
ewbankkit Oct 24, 2023
a1f5fd1
Acceptance test output:
ewbankkit Oct 24, 2023
d0382fc
framework/types: Add 'basetypes.StringTypable' assertions.
ewbankkit Oct 25, 2023
371e73f
Make 'enum.Valueser' public.
ewbankkit Oct 25, 2023
3ed5a96
framework/types: Add 'StringEnum[T]'.
ewbankkit Oct 25, 2023
63472b0
frameowkr/types: Implement 'ARNType' as an extension of 'StringType'.
ewbankkit Oct 25, 2023
d8e991d
'StringEnumType struct ' -> 'stringEnumType struct'.
ewbankkit Oct 26, 2023
32ec69d
Add 'AttributeDefault' to 'stringEnumType'.
ewbankkit Oct 26, 2023
26db9ee
Add 'customStringTypeWithValidator'.
ewbankkit Oct 26, 2023
e59983c
framework/types: Implement 'ARN' as an extension of 'StringValue'.
ewbankkit Oct 26, 2023
2fd2a2c
r/aws_s3control_access_grants_location: Cosmetics.
ewbankkit Oct 26, 2023
25d37e2
r/aws_s3control_access_grant: Initial implementation.
ewbankkit Oct 26, 2023
93a3b7f
autoflex: Update for fuzzy matching fields
YakDriver Oct 24, 2023
2669ee3
autoflex: Check for singular/plural, diff caps fields
YakDriver Oct 24, 2023
c15b595
autoflex: Test new fuzzy find
YakDriver Oct 24, 2023
e4bf659
Update go.mod
YakDriver Oct 24, 2023
d482c41
Add more tests
YakDriver Oct 24, 2023
f73303e
Run 'go mod tidy'.
ewbankkit Oct 26, 2023
6286983
r/aws_s3control_access_grants_location: Use AutoFlEx.
ewbankkit Oct 26, 2023
99c6531
r/aws_s3control_access_grant: Add documentation.
ewbankkit Oct 26, 2023
13ae043
r/aws_s3control_access_grant: Add initial acceptance test.
ewbankkit Oct 26, 2023
28e9411
Use aws_iam_user data source in acceptance tests.
ewbankkit Oct 26, 2023
66c37dc
r/aws_s3control_access_grant: Acceptance test updates.
ewbankkit Oct 27, 2023
79930ef
Add missing CHANGELOG entries.
ewbankkit Oct 27, 2023
b8aea80
Merge commit '66c37dcdff' into HEAD
ewbankkit Oct 27, 2023
6fa4ba5
r/aws_s3control_access_grant: Handle empty AccessGrantsLocationConfig…
ewbankkit Oct 27, 2023
8c89281
Acceptance test output:
ewbankkit Oct 27, 2023
1a8abbd
Add 'testAccAccessGrant_disappears'.
ewbankkit Oct 27, 2023
0f46ead
Add 'testAccAccessGrant_tags'.
ewbankkit Oct 27, 2023
05d57be
Add 'testAccAccessGrant_locationConfiguration'.
ewbankkit Oct 27, 2023
7e0eaa8
Acceptance test output:
ewbankkit Oct 27, 2023
7db47b7
r/aws_s3control_access_grants_instance_resource_policy: Initial imple…
ewbankkit Oct 27, 2023
a6f875e
r/aws_s3control_access_grants_instance_resource_policy: Add documenta…
ewbankkit Oct 27, 2023
652454f
r/aws_s3control_access_grants_instance_resource_policy: Initial accep…
ewbankkit Oct 27, 2023
3ac4673
Add 'validators.JSON'.
ewbankkit Oct 27, 2023
8feb17b
Add 'verify.PolicyStringsEquivalent'.
ewbankkit Oct 27, 2023
afde9f3
Add 'framework/types/IAMPolicy'.
ewbankkit Oct 27, 2023
d1ad026
Tweak type assertions.
ewbankkit Oct 27, 2023
79a13ea
r/aws_s3control_access_grants_instance_resource_policy: Use IAMPolicy…
ewbankkit Oct 27, 2023
6848faf
Acceptance test output:
ewbankkit Oct 27, 2023
63ff303
Add 'testAccAccessGrantsInstanceResourcePolicy_disappears'.
ewbankkit Oct 27, 2023
4dfdd4c
Acceptance test output:
ewbankkit Oct 27, 2023
83910e5
Add S3 Access Grants sweepers.
ewbankkit Oct 30, 2023
2b7defc
Merge branch 'main' into HEAD
ewbankkit Nov 27, 2023
88dd1ff
Correct CHANGELOG entry file name.
ewbankkit Nov 27, 2023
1aaa402
Fix terrafmt error for website documentation.
ewbankkit Nov 27, 2023
4bc9441
Fix terrafmt error for acceptance test configuration.
ewbankkit Nov 27, 2023
b230937
Fix tfproviderdocs error.
ewbankkit Nov 27, 2023
efd9713
s3control: Standardize tagging code generation.
ewbankkit Nov 27, 2023
a1d09d1
r/aws_s3control_access_grants_location: Some renaming.
ewbankkit Nov 27, 2023
b4cfd1b
r/aws_s3control_access_grant: Some renaming.
ewbankkit Nov 27, 2023
d8cbdfa
r/aws_s3control_access_grants_instance_resource_policy: Some renaming.
ewbankkit Nov 27, 2023
d8e89bc
r/aws_s3control_access_grants_instance: Some renaming.
ewbankkit Nov 27, 2023
62e9a72
Access Grants: Restore tests cases that weren't working during beta.
ewbankkit Nov 27, 2023
5a3bbdc
r/aws_s3control_access_grant: Remove hard-coded IAM user from accepta…
ewbankkit Nov 27, 2023
13c685c
r/aws_s3control_access_grants_location: Correct IAM role eventual con…
ewbankkit Nov 27, 2023
351a47c
Remove 'testAccAccessGrantConfig_baseDefaultLocation' -- unused.
ewbankkit Nov 27, 2023
89f73de
r/aws_s3control_access_grants_location: Retry delete on 'AccessGrants…
ewbankkit Nov 27, 2023
c3eae80
r/aws_s3control_access_grant: Retry create on IAM eventual consistenc…
ewbankkit Nov 27, 2023
469e50b
Access Grants: Slightly enhance documentation.
ewbankkit Nov 27, 2023
4e43635
s3control: Standard 2 minute propagation timeout.
ewbankkit Nov 27, 2023
f6725dc
r/aws_s3control_access_grant: Use standard resource ID seperator (',').
ewbankkit Nov 27, 2023
bed3a83
r/aws_s3control_access_grants_location: Use standard resource ID sepe…
ewbankkit Nov 27, 2023
2130457
r/aws_s3control_access_grant: Use correct 'CheckDestroy' function in …
ewbankkit Nov 27, 2023
5bcbdca
r/aws_s3control_access_grant: Correct create retry handling.
ewbankkit Nov 27, 2023
77ffdc9
testAccAccessGrant_disappears: Fix typo.
ewbankkit Nov 27, 2023
2365d9f
Fix golangci-lint 'gomnd'.
ewbankkit Nov 27, 2023
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
15 changes: 15 additions & 0 deletions .changelog/34564.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
```release-note:new-resource
aws_s3control_access_grants_instance
```

```release-note:new-resource
aws_s3control_access_grants_location
```

```release-note:new-resource
aws_s3control_access_grant
```

```release-note:new-resource
aws_s3control_access_grants_instance_resource_policy
```
54 changes: 54 additions & 0 deletions internal/framework/validators/json.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package validators

import (
"context"
"encoding/json"

"github.com/hashicorp/terraform-plugin-framework-validators/helpers/validatordiag"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
)

// jsonValidator validates that a string Attribute's value is valid JSON.
type jsonValidator struct{}

// Description describes the validation in plain text formatting.
func (validator jsonValidator) Description(_ context.Context) string {
return "value must be valid JSON"
}

// MarkdownDescription describes the validation in Markdown formatting.
func (validator jsonValidator) MarkdownDescription(ctx context.Context) string {
return validator.Description(ctx)
}

// Validate performs the validation.
func (validator jsonValidator) ValidateString(ctx context.Context, request validator.StringRequest, response *validator.StringResponse) {
configValue := request.ConfigValue

if configValue.IsNull() || configValue.IsUnknown() {
return
}

// https://datatracker.ietf.org/doc/html/rfc7159.
if valueString := configValue.ValueString(); !json.Valid([]byte(valueString)) {
response.Diagnostics.Append(validatordiag.InvalidAttributeValueDiagnostic(
request.Path,
validator.Description(ctx),
valueString,
))
return
}
}

// JSON returns a string validator which ensures that any configured
// attribute value:
//
// - Is a string, which represents valid JSON.
//
// Null (unconfigured) and unknown (known after apply) values are skipped.
func JSON() validator.String {
return jsonValidator{}
}
67 changes: 67 additions & 0 deletions internal/framework/validators/json_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package validators_test

import (
"context"
"testing"

"github.com/google/go-cmp/cmp"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
"github.com/hashicorp/terraform-plugin-framework/types"
fwvalidators "github.com/hashicorp/terraform-provider-aws/internal/framework/validators"
)

func TestJSONValidator(t *testing.T) {
t.Parallel()

type testCase struct {
val types.String
expectedDiagnostics diag.Diagnostics
}
tests := map[string]testCase{
"unknown String": {
val: types.StringUnknown(),
},
"null String": {
val: types.StringNull(),
},
"invalid String": {
val: types.StringValue("test-value"),
expectedDiagnostics: diag.Diagnostics{
diag.NewAttributeErrorDiagnostic(
path.Root("test"),
"Invalid Attribute Value",
`Attribute test value must be valid JSON, got: test-value`,
),
},
},
"valid JSON": {
val: types.StringValue(`{"Key1": "Value", "Key2": [1, 2, 3]}`),
},
}

for name, test := range tests {
name, test := name, test
t.Run(name, func(t *testing.T) {
t.Parallel()

ctx := context.Background()

request := validator.StringRequest{
Path: path.Root("test"),
PathExpression: path.MatchRoot("test"),
ConfigValue: test.val,
}
response := validator.StringResponse{}
fwvalidators.JSON().ValidateString(ctx, request, &response)

if diff := cmp.Diff(response.Diagnostics, test.expectedDiagnostics); diff != "" {
t.Errorf("unexpected diagnostics difference: %s", diff)
}
})
}
}
1 change: 1 addition & 0 deletions internal/service/s3/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ func RegisterSweepers() {
Dependencies: []string{
"aws_s3_access_point",
"aws_s3_object",
"aws_s3control_access_grants_instance",
"aws_s3control_multi_region_access_point",
},
})
Expand Down
Loading
Loading