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_ec2_network_insights_analysis - new resource #23532

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8135461
r/aws_ec2_network_insights_analysis - new resource
george-richardson Mar 5, 2022
a19b37d
Merge branch 'main' into HEAD
ewbankkit Aug 22, 2022
e8621b8
r/aws_ec2_network_insights_analysis: Correct documentation subcategory.
ewbankkit Aug 22, 2022
624c12a
r/aws_ec2_network_insights_analysis: Rename source files.
ewbankkit Aug 22, 2022
8cd1b4e
Use 'acctest.ProtoV5ProviderFactories'.
ewbankkit Aug 22, 2022
2dca1a0
r/aws_ec2_network_insights_path: Tidy up.
ewbankkit Aug 22, 2022
85c54b7
r/aws_ec2_network_insights_analysis: Use 'WithoutTimeout' CRUD handlers.
ewbankkit Aug 22, 2022
57a9ba5
r/aws_ec2_network_insights_analysis: Add and use 'WaitNetworkInsights…
ewbankkit Aug 22, 2022
1e6416e
r/aws_ec2_network_insights_analysis: Tidy up acceptance tests.
ewbankkit Aug 22, 2022
a2bec96
Fix semgrep 'dgryski.semgrep-go.errnilcheck.err-nil-check'.
ewbankkit Aug 22, 2022
5d94871
Fix terrafmt error.
ewbankkit Aug 22, 2022
01ecf4a
r/aws_ec2_network_insights_analysis: Ensure 'filter_in_arns' elements…
ewbankkit Aug 23, 2022
1037c98
r/aws_ec2_network_insights_analysis: Add 'alternate_path_hints' attri…
ewbankkit Aug 23, 2022
8ce9928
r/aws_ec2_network_insights_analysis: Add 'explanations' attribute.
ewbankkit Aug 23, 2022
6510a08
r/aws_ec2_network_insights_analysis: Add 'forward_path_components' at…
ewbankkit Aug 23, 2022
cdd7abe
r/aws_ec2_network_insights_analysis: Add 'return_path_components' att…
ewbankkit Aug 23, 2022
6c276b6
% make testacc TESTARGS='-run=TestAccVPCNetworkInsightsPath_' PKG=ec2…
ewbankkit Aug 23, 2022
d8e4ce2
Add 'networkInsightsAnalysisPathComponentsSchema'.
ewbankkit Aug 23, 2022
3a82bd9
Add 'networkInsightsAnalysisExplanationsSchema'.
ewbankkit Aug 23, 2022
5fb0945
d/aws_ec2_network_insights_analysis: New data source.
ewbankkit Aug 23, 2022
97744d9
d/aws_ec2_network_insights_analysis: New data source.
ewbankkit Aug 23, 2022
0baad93
Fix semgrep 'ci.caps2-in-func-name'.
ewbankkit Aug 23, 2022
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
11 changes: 11 additions & 0 deletions .changelog/23532.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```release-note:new-resource
aws_ec2_network_insights_analysis
```

```release-note:new-data-source
aws_ec2_network_insights_path
```

```release-note:new-data-source
aws_ec2_network_insights_analysis
```
3 changes: 3 additions & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,8 @@ func New(_ context.Context) (*schema.Provider, error) {
"aws_ec2_local_gateway": ec2.DataSourceLocalGateway(),
"aws_ec2_local_gateways": ec2.DataSourceLocalGateways(),
"aws_ec2_managed_prefix_list": ec2.DataSourceManagedPrefixList(),
"aws_ec2_network_insights_analysis": ec2.DataSourceNetworkInsightsAnalysis(),
"aws_ec2_network_insights_path": ec2.DataSourceNetworkInsightsPath(),
"aws_ec2_serial_console_access": ec2.DataSourceSerialConsoleAccess(),
"aws_ec2_spot_price": ec2.DataSourceSpotPrice(),
"aws_ec2_transit_gateway": ec2.DataSourceTransitGateway(),
Expand Down Expand Up @@ -1324,6 +1326,7 @@ func New(_ context.Context) (*schema.Provider, error) {
"aws_ec2_local_gateway_route_table_vpc_association": ec2.ResourceLocalGatewayRouteTableVPCAssociation(),
"aws_ec2_managed_prefix_list": ec2.ResourceManagedPrefixList(),
"aws_ec2_managed_prefix_list_entry": ec2.ResourceManagedPrefixListEntry(),
"aws_ec2_network_insights_analysis": ec2.ResourceNetworkInsightsAnalysis(),
"aws_ec2_network_insights_path": ec2.ResourceNetworkInsightsPath(),
"aws_ec2_serial_console_access": ec2.ResourceSerialConsoleAccess(),
"aws_ec2_subnet_cidr_reservation": ec2.ResourceSubnetCIDRReservation(),
Expand Down
1 change: 1 addition & 0 deletions internal/service/ec2/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const (
errCodeInvalidNetworkACLEntryNotFound = "InvalidNetworkAclEntry.NotFound"
errCodeInvalidNetworkACLIDNotFound = "InvalidNetworkAclID.NotFound"
errCodeInvalidNetworkInterfaceIDNotFound = "InvalidNetworkInterfaceID.NotFound"
errCodeInvalidNetworkInsightsAnalysisIdNotFound = "InvalidNetworkInsightsAnalysisId.NotFound"
errCodeInvalidNetworkInsightsPathIdNotFound = "InvalidNetworkInsightsPathId.NotFound"
errCodeInvalidParameter = "InvalidParameter"
errCodeInvalidParameterException = "InvalidParameterException"
Expand Down
82 changes: 76 additions & 6 deletions internal/service/ec2/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -1460,8 +1460,8 @@ func FindNetworkInterfaceSecurityGroup(conn *ec2.EC2, networkInterfaceID string,
}
}

func FindNetworkInsightsPath(conn *ec2.EC2, input *ec2.DescribeNetworkInsightsPathsInput) (*ec2.NetworkInsightsPath, error) {
output, err := FindNetworkInsightsPaths(conn, input)
func FindNetworkInsightsAnalysis(ctx context.Context, conn *ec2.EC2, input *ec2.DescribeNetworkInsightsAnalysesInput) (*ec2.NetworkInsightsAnalysis, error) {
output, err := FindNetworkInsightsAnalyses(ctx, conn, input)

if err != nil {
return nil, err
Expand All @@ -1478,10 +1478,80 @@ func FindNetworkInsightsPath(conn *ec2.EC2, input *ec2.DescribeNetworkInsightsPa
return output[0], nil
}

func FindNetworkInsightsPaths(conn *ec2.EC2, input *ec2.DescribeNetworkInsightsPathsInput) ([]*ec2.NetworkInsightsPath, error) {
func FindNetworkInsightsAnalyses(ctx context.Context, conn *ec2.EC2, input *ec2.DescribeNetworkInsightsAnalysesInput) ([]*ec2.NetworkInsightsAnalysis, error) {
var output []*ec2.NetworkInsightsAnalysis

err := conn.DescribeNetworkInsightsAnalysesPagesWithContext(ctx, input, func(page *ec2.DescribeNetworkInsightsAnalysesOutput, lastPage bool) bool {
if page == nil {
return !lastPage
}

for _, v := range page.NetworkInsightsAnalyses {
if v != nil {
output = append(output, v)
}
}

return !lastPage
})

if tfawserr.ErrCodeEquals(err, errCodeInvalidNetworkInsightsAnalysisIdNotFound) {
return nil, &resource.NotFoundError{
LastError: err,
LastRequest: input,
}
}

if err != nil {
return nil, err
}

return output, nil
}

func FindNetworkInsightsAnalysisByID(ctx context.Context, conn *ec2.EC2, id string) (*ec2.NetworkInsightsAnalysis, error) {
input := &ec2.DescribeNetworkInsightsAnalysesInput{
NetworkInsightsAnalysisIds: aws.StringSlice([]string{id}),
}

output, err := FindNetworkInsightsAnalysis(ctx, conn, input)

if err != nil {
return nil, err
}

// Eventual consistency check.
if aws.StringValue(output.NetworkInsightsAnalysisId) != id {
return nil, &resource.NotFoundError{
LastRequest: input,
}
}

return output, nil
}

func FindNetworkInsightsPath(ctx context.Context, conn *ec2.EC2, input *ec2.DescribeNetworkInsightsPathsInput) (*ec2.NetworkInsightsPath, error) {
output, err := FindNetworkInsightsPaths(ctx, conn, input)

if err != nil {
return nil, err
}

if len(output) == 0 || output[0] == nil {
return nil, tfresource.NewEmptyResultError(input)
}

if count := len(output); count > 1 {
return nil, tfresource.NewTooManyResultsError(count, input)
}

return output[0], nil
}

func FindNetworkInsightsPaths(ctx context.Context, conn *ec2.EC2, input *ec2.DescribeNetworkInsightsPathsInput) ([]*ec2.NetworkInsightsPath, error) {
var output []*ec2.NetworkInsightsPath

err := conn.DescribeNetworkInsightsPathsPages(input, func(page *ec2.DescribeNetworkInsightsPathsOutput, lastPage bool) bool {
err := conn.DescribeNetworkInsightsPathsPagesWithContext(ctx, input, func(page *ec2.DescribeNetworkInsightsPathsOutput, lastPage bool) bool {
if page == nil {
return !lastPage
}
Expand Down Expand Up @@ -1509,12 +1579,12 @@ func FindNetworkInsightsPaths(conn *ec2.EC2, input *ec2.DescribeNetworkInsightsP
return output, nil
}

func FindNetworkInsightsPathByID(conn *ec2.EC2, id string) (*ec2.NetworkInsightsPath, error) {
func FindNetworkInsightsPathByID(ctx context.Context, conn *ec2.EC2, id string) (*ec2.NetworkInsightsPath, error) {
input := &ec2.DescribeNetworkInsightsPathsInput{
NetworkInsightsPathIds: aws.StringSlice([]string{id}),
}

output, err := FindNetworkInsightsPath(conn, input)
output, err := FindNetworkInsightsPath(ctx, conn, input)

if err != nil {
return nil, err
Expand Down
16 changes: 16 additions & 0 deletions internal/service/ec2/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,22 @@ func StatusManagedPrefixListState(conn *ec2.EC2, id string) resource.StateRefres
}
}

func StatusNetworkInsightsAnalysis(ctx context.Context, conn *ec2.EC2, id string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
output, err := FindNetworkInsightsAnalysisByID(ctx, conn, id)

if tfresource.NotFound(err) {
return nil, "", nil
}

if err != nil {
return nil, "", err
}

return output, aws.StringValue(output.Status), nil
}
}

func StatusNetworkInterfaceStatus(conn *ec2.EC2, id string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
output, err := FindNetworkInterfaceByID(conn, id)
Expand Down
Loading