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

resource/aws_transfer_server: Add support for VPC security groups #17539

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
472a694
ADd new key
Feb 2, 2021
a1aa8ed
Change
Feb 2, 2021
fc1a437
Add security_group_ids parameter.
Feb 4, 2021
2d4c47c
change
Feb 4, 2021
8d2dd00
change
Feb 4, 2021
708b267
Change
Feb 4, 2021
e1751a8
Change
Feb 4, 2021
82f0197
Update
Feb 6, 2021
240e445
Update Doc
Feb 6, 2021
f8a6237
Add go.yaml
Feb 9, 2021
4b191fb
Change
Feb 9, 2021
54698e8
Change
Feb 9, 2021
1183799
Change
Feb 9, 2021
18f986a
Change
Feb 9, 2021
c439ede
Change only one line
Feb 9, 2021
471c29e
Change
Feb 9, 2021
f96aaa9
Add changelog
Feb 10, 2021
8ab5322
Add changelog, reset .goreleaser.yml and fix aws/resource_aws_transfe…
Feb 16, 2021
083b518
A little change
Feb 19, 2021
3660eb6
Return .goreleaser.yml and CHANGELOG.md to original state
Feb 17, 2021
e6d2320
Remove Custom workflow files
Feb 17, 2021
9c72f21
Change
Feb 26, 2021
64d2c2b
Update .changelog/17539.txt
amadureira Feb 26, 2021
5a01d01
Tidy up after rebase.
ewbankkit Jun 28, 2021
0b55299
r/aws_transfer_server: Add TODOs for security group ID updates.
ewbankkit Jun 28, 2021
a470bb6
r/aws_transfer_server: Enhance 'TestAccAWSTransferServer_vpc'.
ewbankkit Jun 28, 2021
3ebf3a2
r/aws_transfer_server: Security Group IDs are not Computed.
ewbankkit Jun 29, 2021
d320a06
r/aws_transfer_server: 'force_destroy' only applies to SERVICE_MANAGE…
ewbankkit Jun 17, 2021
4a36d75
Serialize Transfer acceptance tests.
ewbankkit Jun 17, 2021
47f3107
r/aws_transfer_server: Prevent "InvalidRequestException: Changing Vpc…
ewbankkit Jun 29, 2021
19d7ee9
r/aws_transfer_server: Read security group IDs via EC2 DecsribeVpcEnd…
ewbankkit Jun 29, 2021
fedf8cd
r/aws_transfer_server: Additional tests.
ewbankkit Jun 30, 2021
5d26d2a
r/aws_transfer_server: Use Amazon EC2 ModifyVpcEndpoint API to modify…
ewbankkit Jun 30, 2021
41048b9
Prevent 'severity:warning rule:aws-sdk-go-multiple-service-imports: R…
ewbankkit Jun 30, 2021
d2d0ce5
Fix 'terrafmt' errors.
ewbankkit Jun 30, 2021
e7c7b31
r/aws_transfer_server: Add tests to set no VPC subnet IDs or security…
ewbankkit Jul 1, 2021
d635b87
r/aws_vpc_endpoint: Ignore errors such as
ewbankkit Jul 1, 2021
725e40d
r/aws_transfer_server: Correct update to 0 subnet_ids.
ewbankkit Jul 2, 2021
549d814
r/aws_transfer_server: Cannot update to 0 security_group_ids (VPC End…
ewbankkit Jul 2, 2021
fe8cda6
r/aws_transfer_server: When updating endpoint_type to VPC, wait for n…
ewbankkit Jul 2, 2021
7c0c8d0
Fix rebase merge conflicts.
ewbankkit Jul 2, 2021
baffc39
Call out use of EC2 DescribeVpcEndpoints/ModifyVpcEndpoint actions.
ewbankkit Jul 2, 2021
d6a8e53
r/aws_transfer_server: Handle 'InvalidRequestException: AddressAlloca…
ewbankkit Jul 2, 2021
f3cf2ce
r/aws_transfer_server: Simplify some acceptance tests.
ewbankkit Jul 2, 2021
678491c
Simplify acceptance test configurations.
ewbankkit Jul 2, 2021
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
3 changes: 3 additions & 0 deletions .changelog/17539.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_transfer_server: Add `security_group_ids` argument to `endpoint_details` configuration block.
```
1 change: 1 addition & 0 deletions .semgrep.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ rules:
- aws/validators.go
- aws/*wafregional*.go
- aws/resource_aws_serverlessapplicationrepository_cloudformation_stack.go
- aws/resource_aws_transfer_server.go
- aws/*_test.go
- aws/internal/keyvaluetags/
- aws/internal/service/wafregional/
Expand Down
4 changes: 3 additions & 1 deletion aws/internal/service/ec2/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/ec2"
multierror "github.com/hashicorp/go-multierror"
)
Expand Down Expand Up @@ -69,6 +70,7 @@ const (

const (
ErrCodeInvalidVpcEndpointIdNotFound = "InvalidVpcEndpointId.NotFound"
ErrCodeInvalidVpcEndpointNotFound = "InvalidVpcEndpoint.NotFound"
ErrCodeInvalidVpcEndpointServiceIdNotFound = "InvalidVpcEndpointServiceId.NotFound"
)

Expand All @@ -86,7 +88,7 @@ func UnsuccessfulItemError(apiObject *ec2.UnsuccessfulItemError) error {
return nil
}

return fmt.Errorf("%s: %s", aws.StringValue(apiObject.Code), aws.StringValue(apiObject.Message))
return awserr.New(aws.StringValue(apiObject.Code), aws.StringValue(apiObject.Message), nil)
}

func UnsuccessfulItemsError(apiObjects []*ec2.UnsuccessfulItem) error {
Expand Down
133 changes: 133 additions & 0 deletions aws/internal/service/ec2/errors_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
package ec2_test

import (
"testing"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/hashicorp/aws-sdk-go-base/tfawserr"
tfec2 "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/ec2"
)

func TestUnsuccessfulItemError(t *testing.T) {
unsuccessfulItemError := &ec2.UnsuccessfulItemError{
Code: aws.String("test code"),
Message: aws.String("test message"),
}

err := tfec2.UnsuccessfulItemError(unsuccessfulItemError)

if !tfawserr.ErrCodeEquals(err, "test code") {
t.Errorf("tfawserr.ErrCodeEquals failed: %s", err)
}

if !tfawserr.ErrMessageContains(err, "test code", "est mess") {
t.Errorf("tfawserr.ErrMessageContains failed: %s", err)
}
}

func TestUnsuccessfulItemsError(t *testing.T) {
testCases := []struct {
Name string
Items []*ec2.UnsuccessfulItem
Expected bool
}{
{
Name: "no items",
},
{
Name: "one item no error",
Items: []*ec2.UnsuccessfulItem{
{
ResourceId: aws.String("test resource"),
},
},
},
{
Name: "one item",
Items: []*ec2.UnsuccessfulItem{
{
Error: &ec2.UnsuccessfulItemError{
Code: aws.String("test code"),
Message: aws.String("test message"),
},
ResourceId: aws.String("test resource"),
},
},
Expected: true,
},
{
Name: "two items, first no error",
Items: []*ec2.UnsuccessfulItem{
{
ResourceId: aws.String("test resource 1"),
},
{
Error: &ec2.UnsuccessfulItemError{
Code: aws.String("test code"),
Message: aws.String("test message"),
},
ResourceId: aws.String("test resource 2"),
},
},
Expected: true,
},
{
Name: "two items, first not as expected",
Items: []*ec2.UnsuccessfulItem{
{
Error: &ec2.UnsuccessfulItemError{
Code: aws.String("not what is required"),
Message: aws.String("not what is wanted"),
},
ResourceId: aws.String("test resource 1"),
},
{
Error: &ec2.UnsuccessfulItemError{
Code: aws.String("test code"),
Message: aws.String("test message"),
},
ResourceId: aws.String("test resource 2"),
},
},
},
{
Name: "two items, first as expected",
Items: []*ec2.UnsuccessfulItem{
{
Error: &ec2.UnsuccessfulItemError{
Code: aws.String("test code"),
Message: aws.String("test message"),
},
ResourceId: aws.String("test resource 1"),
},
{
Error: &ec2.UnsuccessfulItemError{
Code: aws.String("not what is required"),
Message: aws.String("not what is wanted"),
},
ResourceId: aws.String("test resource 2"),
},
},
Expected: true,
},
}

for _, testCase := range testCases {
t.Run(testCase.Name, func(t *testing.T) {
err := tfec2.UnsuccessfulItemsError(testCase.Items)

got := tfawserr.ErrCodeEquals(err, "test code")

if got != testCase.Expected {
t.Errorf("ErrCodeEquals got %t, expected %t", got, testCase.Expected)
}

got = tfawserr.ErrMessageContains(err, "test code", "est mess")

if got != testCase.Expected {
t.Errorf("ErrMessageContains got %t, expected %t", got, testCase.Expected)
}
})
}
}
15 changes: 15 additions & 0 deletions aws/internal/service/transfer/enum.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package transfer

const (
SecurityPolicyName2018_11 = "TransferSecurityPolicy-2018-11"
SecurityPolicyName2020_06 = "TransferSecurityPolicy-2020-06"
SecurityPolicyNameFIPS_2020_06 = "TransferSecurityPolicy-FIPS-2020-06"
)

func SecurityPolicyName_Values() []string {
return []string{
SecurityPolicyName2018_11,
SecurityPolicyName2020_06,
SecurityPolicyNameFIPS_2020_06,
}
}
Loading