diff --git a/.changelog/36966.txt b/.changelog/36966.txt new file mode 100644 index 00000000000..f17f986bc81 --- /dev/null +++ b/.changelog/36966.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_ec2_network_insights_path: Mark `destination` as Optional +``` \ No newline at end of file diff --git a/go.mod b/go.mod index 56b93522468..fdc6875ad3a 100644 --- a/go.mod +++ b/go.mod @@ -154,6 +154,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/route53 v1.40.10 github.com/aws/aws-sdk-go-v2/service/route53domains v1.23.10 github.com/aws/aws-sdk-go-v2/service/route53profiles v1.0.7 + github.com/aws/aws-sdk-go-v2/service/rum v1.17.12 github.com/aws/aws-sdk-go-v2/service/s3 v1.55.1 github.com/aws/aws-sdk-go-v2/service/s3control v1.44.13 github.com/aws/aws-sdk-go-v2/service/scheduler v1.8.10 diff --git a/go.sum b/go.sum index f73f5823c5c..319629722a0 100644 --- a/go.sum +++ b/go.sum @@ -338,6 +338,8 @@ github.com/aws/aws-sdk-go-v2/service/route53domains v1.23.10 h1:R56F/k3CQZHwrd3k github.com/aws/aws-sdk-go-v2/service/route53domains v1.23.10/go.mod h1:W3+eDMk01Na1U3aQfwGkkEP1Yfe6WUn8hXzyInvGlcU= github.com/aws/aws-sdk-go-v2/service/route53profiles v1.0.7 h1:32/NRAG4ka8/hwr1k9ZA2xwarcJeWO6djaIFJ42tuFg= github.com/aws/aws-sdk-go-v2/service/route53profiles v1.0.7/go.mod h1:H9RRL0qQ+s+XlaZO5s5G3Z8cVZpKEoj313hOyglUwj0= +github.com/aws/aws-sdk-go-v2/service/rum v1.17.12 h1:QeR9ldfI/Hf5sNgvMKi/lnyTKqhg8DQ/BUlRBUuF2tA= +github.com/aws/aws-sdk-go-v2/service/rum v1.17.12/go.mod h1:sd4DiDquert2Ds9FJXnRj8v/78A682gIz1dxjiMRy/I= github.com/aws/aws-sdk-go-v2/service/s3 v1.55.1 h1:UAxBuh0/8sFJk1qOkvOKewP5sWeWaTPDknbQz0ZkDm0= github.com/aws/aws-sdk-go-v2/service/s3 v1.55.1/go.mod h1:hWjsYGjVuqCgfoveVcVFPXIWgz0aByzwaxKlN1StKcM= github.com/aws/aws-sdk-go-v2/service/s3control v1.44.13 h1:HhsZlX5gsL/KfEyHyBO5H0ewgmXoiBpjDPAZ3Ggrj8g= diff --git a/internal/conns/awsclient_gen.go b/internal/conns/awsclient_gen.go index fa56803e051..5efb8fed9d6 100644 --- a/internal/conns/awsclient_gen.go +++ b/internal/conns/awsclient_gen.go @@ -146,6 +146,7 @@ import ( route53_sdkv2 "github.com/aws/aws-sdk-go-v2/service/route53" route53domains_sdkv2 "github.com/aws/aws-sdk-go-v2/service/route53domains" route53profiles_sdkv2 "github.com/aws/aws-sdk-go-v2/service/route53profiles" + rum_sdkv2 "github.com/aws/aws-sdk-go-v2/service/rum" s3_sdkv2 "github.com/aws/aws-sdk-go-v2/service/s3" s3control_sdkv2 "github.com/aws/aws-sdk-go-v2/service/s3control" scheduler_sdkv2 "github.com/aws/aws-sdk-go-v2/service/scheduler" @@ -188,7 +189,6 @@ import ( backup_sdkv1 "github.com/aws/aws-sdk-go/service/backup" batch_sdkv1 "github.com/aws/aws-sdk-go/service/batch" chime_sdkv1 "github.com/aws/aws-sdk-go/service/chime" - cloudwatchrum_sdkv1 "github.com/aws/aws-sdk-go/service/cloudwatchrum" cognitoidentityprovider_sdkv1 "github.com/aws/aws-sdk-go/service/cognitoidentityprovider" connect_sdkv1 "github.com/aws/aws-sdk-go/service/connect" databasemigrationservice_sdkv1 "github.com/aws/aws-sdk-go/service/databasemigrationservice" @@ -991,8 +991,8 @@ func (c *AWSClient) RDSClient(ctx context.Context) *rds_sdkv2.Client { return errs.Must(client[*rds_sdkv2.Client](ctx, c, names.RDS, make(map[string]any))) } -func (c *AWSClient) RUMConn(ctx context.Context) *cloudwatchrum_sdkv1.CloudWatchRUM { - return errs.Must(conn[*cloudwatchrum_sdkv1.CloudWatchRUM](ctx, c, names.RUM, make(map[string]any))) +func (c *AWSClient) RUMClient(ctx context.Context) *rum_sdkv2.Client { + return errs.Must(client[*rum_sdkv2.Client](ctx, c, names.RUM, make(map[string]any))) } func (c *AWSClient) RedshiftConn(ctx context.Context) *redshift_sdkv1.Redshift { diff --git a/internal/service/ec2/exports_test.go b/internal/service/ec2/exports_test.go index 2139b2e7579..5a849ec8e40 100644 --- a/internal/service/ec2/exports_test.go +++ b/internal/service/ec2/exports_test.go @@ -49,6 +49,8 @@ var ( ResourceMainRouteTableAssociation = resourceMainRouteTableAssociation ResourceNetworkACL = resourceNetworkACL ResourceNetworkACLRule = resourceNetworkACLRule + ResourceNetworkInsightsAnalysis = resourceNetworkInsightsAnalysis + ResourceNetworkInsightsPath = resourceNetworkInsightsPath ResourceNetworkInterface = resourceNetworkInterface ResourcePlacementGroup = resourcePlacementGroup ResourceRoute = resourceRoute @@ -123,6 +125,8 @@ var ( FindLaunchTemplateByID = findLaunchTemplateByID FindMainRouteTableAssociationByID = findMainRouteTableAssociationByID FindNetworkACLByIDV2 = findNetworkACLByID + FindNetworkInsightsAnalysisByID = findNetworkInsightsAnalysisByID + FindNetworkInsightsPathByID = findNetworkInsightsPathByID FindNetworkInterfaceByIDV2 = findNetworkInterfaceByID FindNetworkPerformanceMetricSubscriptionByFourPartKey = findNetworkPerformanceMetricSubscriptionByFourPartKey FindPlacementGroupByName = findPlacementGroupByName diff --git a/internal/service/ec2/find.go b/internal/service/ec2/find.go index 9216faaa95e..fd9d21fbb90 100644 --- a/internal/service/ec2/find.go +++ b/internal/service/ec2/find.go @@ -414,130 +414,6 @@ func FindNetworkInterfaceSecurityGroup(ctx context.Context, conn *ec2.EC2, netwo } } -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 - } - - return tfresource.AssertSinglePtrResult(output) -} - -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, &retry.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, &retry.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 - } - - return tfresource.AssertSinglePtrResult(output) -} - -func FindNetworkInsightsPaths(ctx context.Context, conn *ec2.EC2, input *ec2.DescribeNetworkInsightsPathsInput) ([]*ec2.NetworkInsightsPath, error) { - var output []*ec2.NetworkInsightsPath - - err := conn.DescribeNetworkInsightsPathsPagesWithContext(ctx, input, func(page *ec2.DescribeNetworkInsightsPathsOutput, lastPage bool) bool { - if page == nil { - return !lastPage - } - - for _, v := range page.NetworkInsightsPaths { - if v != nil { - output = append(output, v) - } - } - - return !lastPage - }) - - if tfawserr.ErrCodeEquals(err, errCodeInvalidNetworkInsightsPathIdNotFound) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: input, - } - } - - if err != nil { - return nil, err - } - - return output, nil -} - -func FindNetworkInsightsPathByID(ctx context.Context, conn *ec2.EC2, id string) (*ec2.NetworkInsightsPath, error) { - input := &ec2.DescribeNetworkInsightsPathsInput{ - NetworkInsightsPathIds: aws.StringSlice([]string{id}), - } - - output, err := FindNetworkInsightsPath(ctx, conn, input) - - if err != nil { - return nil, err - } - - // Eventual consistency check. - if aws.StringValue(output.NetworkInsightsPathId) != id { - return nil, &retry.NotFoundError{ - LastRequest: input, - } - } - - return output, nil -} - func FindSecurityGroupByID(ctx context.Context, conn *ec2.EC2, id string) (*ec2.SecurityGroup, error) { input := &ec2.DescribeSecurityGroupsInput{ GroupIds: aws.StringSlice([]string{id}), diff --git a/internal/service/ec2/findv2.go b/internal/service/ec2/findv2.go index 1160e5fa96e..e60f977bc01 100644 --- a/internal/service/ec2/findv2.go +++ b/internal/service/ec2/findv2.go @@ -5265,3 +5265,113 @@ func findTrafficMirrorTargetByID(ctx context.Context, conn *ec2.Client, id strin return output, nil } + +func findNetworkInsightsPath(ctx context.Context, conn *ec2.Client, input *ec2.DescribeNetworkInsightsPathsInput) (*awstypes.NetworkInsightsPath, error) { + output, err := findNetworkInsightsPaths(ctx, conn, input) + + if err != nil { + return nil, err + } + + return tfresource.AssertSingleValueResult(output) +} + +func findNetworkInsightsAnalysis(ctx context.Context, conn *ec2.Client, input *ec2.DescribeNetworkInsightsAnalysesInput) (*awstypes.NetworkInsightsAnalysis, error) { + output, err := findNetworkInsightsAnalyses(ctx, conn, input) + + if err != nil { + return nil, err + } + + return tfresource.AssertSingleValueResult(output) +} + +func findNetworkInsightsAnalyses(ctx context.Context, conn *ec2.Client, input *ec2.DescribeNetworkInsightsAnalysesInput) ([]awstypes.NetworkInsightsAnalysis, error) { + var output []awstypes.NetworkInsightsAnalysis + + pages := ec2.NewDescribeNetworkInsightsAnalysesPaginator(conn, input) + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if tfawserr.ErrCodeEquals(err, errCodeInvalidNetworkInsightsAnalysisIdNotFound) { + return nil, &retry.NotFoundError{ + LastError: err, + LastRequest: input, + } + } + + if err != nil { + return nil, err + } + + output = append(output, page.NetworkInsightsAnalyses...) + } + + return output, nil +} + +func findNetworkInsightsAnalysisByID(ctx context.Context, conn *ec2.Client, id string) (*awstypes.NetworkInsightsAnalysis, error) { + input := &ec2.DescribeNetworkInsightsAnalysesInput{ + NetworkInsightsAnalysisIds: []string{id}, + } + + output, err := findNetworkInsightsAnalysis(ctx, conn, input) + + if err != nil { + return nil, err + } + + // Eventual consistency check. + if aws.ToString(output.NetworkInsightsAnalysisId) != id { + return nil, &retry.NotFoundError{ + LastRequest: input, + } + } + + return output, nil +} + +func findNetworkInsightsPaths(ctx context.Context, conn *ec2.Client, input *ec2.DescribeNetworkInsightsPathsInput) ([]awstypes.NetworkInsightsPath, error) { + var output []awstypes.NetworkInsightsPath + + pages := ec2.NewDescribeNetworkInsightsPathsPaginator(conn, input) + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if tfawserr.ErrCodeEquals(err, errCodeInvalidNetworkInsightsPathIdNotFound) { + return nil, &retry.NotFoundError{ + LastError: err, + LastRequest: input, + } + } + + if err != nil { + return nil, err + } + + output = append(output, page.NetworkInsightsPaths...) + } + + return output, nil +} + +func findNetworkInsightsPathByID(ctx context.Context, conn *ec2.Client, id string) (*awstypes.NetworkInsightsPath, error) { + input := &ec2.DescribeNetworkInsightsPathsInput{ + NetworkInsightsPathIds: []string{id}, + } + + output, err := findNetworkInsightsPath(ctx, conn, input) + + if err != nil { + return nil, err + } + + // Eventual consistency check. + if aws.ToString(output.NetworkInsightsPathId) != id { + return nil, &retry.NotFoundError{ + LastRequest: input, + } + } + + return output, nil +} diff --git a/internal/service/ec2/service_package_gen.go b/internal/service/ec2/service_package_gen.go index 54d1fe64244..9c3ef9b110a 100644 --- a/internal/service/ec2/service_package_gen.go +++ b/internal/service/ec2/service_package_gen.go @@ -220,12 +220,16 @@ func (p *servicePackage) SDKDataSources(ctx context.Context) []*types.ServicePac TypeName: "aws_ec2_managed_prefix_lists", }, { - Factory: DataSourceNetworkInsightsAnalysis, + Factory: dataSourceNetworkInsightsAnalysis, TypeName: "aws_ec2_network_insights_analysis", + Name: "Network Insights Analysis", + Tags: &types.ServicePackageResourceTags{}, }, { - Factory: DataSourceNetworkInsightsPath, + Factory: dataSourceNetworkInsightsPath, TypeName: "aws_ec2_network_insights_path", + Name: "Network Insights Path", + Tags: &types.ServicePackageResourceTags{}, }, { Factory: dataSourcePublicIPv4Pool, @@ -714,7 +718,7 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka TypeName: "aws_ec2_managed_prefix_list_entry", }, { - Factory: ResourceNetworkInsightsAnalysis, + Factory: resourceNetworkInsightsAnalysis, TypeName: "aws_ec2_network_insights_analysis", Name: "Network Insights Analysis", Tags: &types.ServicePackageResourceTags{ @@ -722,7 +726,7 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka }, }, { - Factory: ResourceNetworkInsightsPath, + Factory: resourceNetworkInsightsPath, TypeName: "aws_ec2_network_insights_path", Name: "Network Insights Path", Tags: &types.ServicePackageResourceTags{ diff --git a/internal/service/ec2/status.go b/internal/service/ec2/status.go index 8099827ce96..b0724f08db6 100644 --- a/internal/service/ec2/status.go +++ b/internal/service/ec2/status.go @@ -378,22 +378,6 @@ func StatusManagedPrefixListState(ctx context.Context, conn *ec2.EC2, id string) } } -func StatusNetworkInsightsAnalysis(ctx context.Context, conn *ec2.EC2, id string) retry.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(ctx context.Context, conn *ec2.EC2, id string) retry.StateRefreshFunc { return func() (interface{}, string, error) { output, err := FindNetworkInterfaceByID(ctx, conn, id) diff --git a/internal/service/ec2/statusv2.go b/internal/service/ec2/statusv2.go index 93ef7bd3e25..1428425b2f4 100644 --- a/internal/service/ec2/statusv2.go +++ b/internal/service/ec2/statusv2.go @@ -1213,3 +1213,19 @@ func statusEBSSnapshotImport(ctx context.Context, conn *ec2.Client, id string) r return output.SnapshotTaskDetail, aws.ToString(output.SnapshotTaskDetail.Status), nil } } + +func statusNetworkInsightsAnalysis(ctx context.Context, conn *ec2.Client, id string) retry.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, string(output.Status), nil + } +} diff --git a/internal/service/ec2/sweep.go b/internal/service/ec2/sweep.go index 0061f66bd95..760bfb77757 100644 --- a/internal/service/ec2/sweep.go +++ b/internal/service/ec2/sweep.go @@ -1378,13 +1378,11 @@ func sweepNetworkInsightsPaths(region string) error { errs = multierror.Append(errs, fmt.Errorf("error listing Network Insights Paths for %s: %w", region, err)) } - for _, nip := range page.NetworkInsightsPaths { - id := aws.ToString(nip.NetworkInsightsPathId) - - r := ResourceNetworkInsightsPath() + for _, v := range page.NetworkInsightsPaths { + r := resourceNetworkInsightsPath() d := r.Data(nil) + d.SetId(aws.ToString(v.NetworkInsightsPathId)) - d.SetId(id) sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client)) } } diff --git a/internal/service/ec2/vpc_network_insights_analysis.go b/internal/service/ec2/vpc_network_insights_analysis.go index d262b061990..7078ab583a0 100644 --- a/internal/service/ec2/vpc_network_insights_analysis.go +++ b/internal/service/ec2/vpc_network_insights_analysis.go @@ -8,9 +8,10 @@ import ( "log" "time" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/ec2" + awstypes "github.com/aws/aws-sdk-go-v2/service/ec2/types" + "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -25,7 +26,7 @@ import ( // @SDKResource("aws_ec2_network_insights_analysis", name="Network Insights Analysis") // @Tags(identifierAttribute="id") // @Testing(tagsTest=false) -func ResourceNetworkInsightsAnalysis() *schema.Resource { +func resourceNetworkInsightsAnalysis() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceNetworkInsightsAnalysisCreate, ReadWithoutTimeout: resourceNetworkInsightsAnalysisRead, @@ -36,1400 +37,1404 @@ func ResourceNetworkInsightsAnalysis() *schema.Resource { StateContext: schema.ImportStatePassthroughContext, }, - Schema: map[string]*schema.Schema{ - "alternate_path_hints": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "component_arn": { - Type: schema.TypeString, - Computed: true, - }, - "component_id": { - Type: schema.TypeString, - Computed: true, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "alternate_path_hints": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "component_arn": { + Type: schema.TypeString, + Computed: true, + }, + "component_id": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - "explanations": networkInsightsAnalysisExplanationsSchema, - "filter_in_arns": { - Type: schema.TypeSet, - Optional: true, - ForceNew: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: verify.ValidARN, + names.AttrARN: { + Type: schema.TypeString, + Computed: true, }, - }, - "forward_path_components": networkInsightsAnalysisPathComponentsSchema, - "network_insights_path_id": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - "path_found": { - Type: schema.TypeBool, - Computed: true, - }, - "return_path_components": networkInsightsAnalysisPathComponentsSchema, - "start_date": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrStatus: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrStatusMessage: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTags: tftags.TagsSchema(), - names.AttrTagsAll: tftags.TagsSchemaComputed(), - "wait_for_completion": { - Type: schema.TypeBool, - Optional: true, - Default: true, - }, - "warning_message": { - Type: schema.TypeString, - Computed: true, - }, + "explanations": networkInsightsAnalysisExplanationsSchema(), + "filter_in_arns": { + Type: schema.TypeSet, + Optional: true, + ForceNew: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + ValidateFunc: verify.ValidARN, + }, + }, + "forward_path_components": networkInsightsAnalysisPathComponentsSchema(), + "network_insights_path_id": { + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "path_found": { + Type: schema.TypeBool, + Computed: true, + }, + "return_path_components": networkInsightsAnalysisPathComponentsSchema(), + "start_date": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrStatus: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrStatusMessage: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTags: tftags.TagsSchema(), + names.AttrTagsAll: tftags.TagsSchemaComputed(), + "wait_for_completion": { + Type: schema.TypeBool, + Optional: true, + Default: true, + }, + "warning_message": { + Type: schema.TypeString, + Computed: true, + }, + } }, CustomizeDiff: verify.SetTagsDiff, } } -var networkInsightsAnalysisPathComponentsSchema = &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "acl_rule": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cidr": { - Type: schema.TypeString, - Computed: true, - }, - "egress": { - Type: schema.TypeBool, - Computed: true, - }, - "port_range": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "from": { - Type: schema.TypeInt, - Computed: true, - }, - "to": { - Type: schema.TypeInt, - Computed: true, +func networkInsightsAnalysisPathComponentsSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "acl_rule": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cidr": { + Type: schema.TypeString, + Computed: true, + }, + "egress": { + Type: schema.TypeBool, + Computed: true, + }, + "port_range": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "from": { + Type: schema.TypeInt, + Computed: true, + }, + "to": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, - }, - names.AttrProtocol: { - Type: schema.TypeString, - Computed: true, - }, - "rule_action": { - Type: schema.TypeString, - Computed: true, - }, - "rule_number": { - Type: schema.TypeInt, - Computed: true, + names.AttrProtocol: { + Type: schema.TypeString, + Computed: true, + }, + "rule_action": { + Type: schema.TypeString, + Computed: true, + }, + "rule_number": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, - }, - "additional_details": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "additional_detail_type": { - Type: schema.TypeString, - Computed: true, - }, - "component": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "additional_details": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "additional_detail_type": { + Type: schema.TypeString, + Computed: true, + }, + "component": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, }, }, }, - }, - "attached_to": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "attached_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "component": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "component": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "destination_vpc": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "destination_vpc": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "inbound_header": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "destination_addresses": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destination_port_ranges": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "from": { - Type: schema.TypeInt, - Computed: true, - }, - "to": { - Type: schema.TypeInt, - Computed: true, + "inbound_header": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "destination_addresses": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destination_port_ranges": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "from": { + Type: schema.TypeInt, + Computed: true, + }, + "to": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, - }, - names.AttrProtocol: { - Type: schema.TypeString, - Computed: true, - }, - "source_addresses": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "source_port_ranges": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "from": { - Type: schema.TypeInt, - Computed: true, - }, - "to": { - Type: schema.TypeInt, - Computed: true, + names.AttrProtocol: { + Type: schema.TypeString, + Computed: true, + }, + "source_addresses": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "source_port_ranges": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "from": { + Type: schema.TypeInt, + Computed: true, + }, + "to": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, }, }, }, - }, - "outbound_header": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "destination_addresses": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "destination_port_ranges": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "from": { - Type: schema.TypeInt, - Computed: true, - }, - "to": { - Type: schema.TypeInt, - Computed: true, + "outbound_header": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "destination_addresses": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "destination_port_ranges": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "from": { + Type: schema.TypeInt, + Computed: true, + }, + "to": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, - }, - names.AttrProtocol: { - Type: schema.TypeString, - Computed: true, - }, - "source_addresses": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "source_port_ranges": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "from": { - Type: schema.TypeInt, - Computed: true, - }, - "to": { - Type: schema.TypeInt, - Computed: true, + names.AttrProtocol: { + Type: schema.TypeString, + Computed: true, + }, + "source_addresses": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "source_port_ranges": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "from": { + Type: schema.TypeInt, + Computed: true, + }, + "to": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, }, }, }, - }, - "route_table_route": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "destination_cidr": { - Type: schema.TypeString, - Computed: true, - }, - "destination_prefix_list_id": { - Type: schema.TypeString, - Computed: true, - }, - "egress_only_internet_gateway_id": { - Type: schema.TypeString, - Computed: true, - }, - "gateway_id": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrInstanceID: { - Type: schema.TypeString, - Computed: true, - }, - "nat_gateway_id": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrNetworkInterfaceID: { - Type: schema.TypeString, - Computed: true, - }, - "origin": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTransitGatewayID: { - Type: schema.TypeString, - Computed: true, - }, - "vpc_peering_connection_id": { - Type: schema.TypeString, - Computed: true, + "route_table_route": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "destination_cidr": { + Type: schema.TypeString, + Computed: true, + }, + "destination_prefix_list_id": { + Type: schema.TypeString, + Computed: true, + }, + "egress_only_internet_gateway_id": { + Type: schema.TypeString, + Computed: true, + }, + "gateway_id": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrInstanceID: { + Type: schema.TypeString, + Computed: true, + }, + "nat_gateway_id": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrNetworkInterfaceID: { + Type: schema.TypeString, + Computed: true, + }, + "origin": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTransitGatewayID: { + Type: schema.TypeString, + Computed: true, + }, + "vpc_peering_connection_id": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "security_group_rule": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cidr": { - Type: schema.TypeString, - Computed: true, - }, - "direction": { - Type: schema.TypeString, - Computed: true, - }, - "port_range": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "from": { - Type: schema.TypeInt, - Computed: true, - }, - "to": { - Type: schema.TypeInt, - Computed: true, + "security_group_rule": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cidr": { + Type: schema.TypeString, + Computed: true, + }, + "direction": { + Type: schema.TypeString, + Computed: true, + }, + "port_range": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "from": { + Type: schema.TypeInt, + Computed: true, + }, + "to": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, - }, - "prefix_list_id": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrProtocol: { - Type: schema.TypeString, - Computed: true, - }, - "security_group_id": { - Type: schema.TypeString, - Computed: true, + "prefix_list_id": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrProtocol: { + Type: schema.TypeString, + Computed: true, + }, + "security_group_id": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "sequence_number": { - Type: schema.TypeInt, - Computed: true, - }, - "source_vpc": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "sequence_number": { + Type: schema.TypeInt, + Computed: true, + }, + "source_vpc": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "subnet": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "subnet": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "transit_gateway": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "transit_gateway": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "transit_gateway_route_table_route": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "attachment_id": { - Type: schema.TypeString, - Computed: true, - }, - "destination_cidr": { - Type: schema.TypeString, - Computed: true, - }, - "prefix_list_id": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrResourceID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrResourceType: { - Type: schema.TypeString, - Computed: true, - }, - "route_origin": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrState: { - Type: schema.TypeString, - Computed: true, + "transit_gateway_route_table_route": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "attachment_id": { + Type: schema.TypeString, + Computed: true, + }, + "destination_cidr": { + Type: schema.TypeString, + Computed: true, + }, + "prefix_list_id": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrResourceID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrResourceType: { + Type: schema.TypeString, + Computed: true, + }, + "route_origin": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrState: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "vpc": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "vpc": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, }, }, - }, + } } -var networkInsightsAnalysisExplanationsSchema = &schema.Schema{ - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "acl": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, +func networkInsightsAnalysisExplanationsSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "acl": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "acl_rule": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cidr": { - Type: schema.TypeString, - Computed: true, - }, - "egress": { - Type: schema.TypeBool, - Computed: true, - }, - "port_range": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "from": { - Type: schema.TypeInt, - Computed: true, - }, - "to": { - Type: schema.TypeInt, - Computed: true, + "acl_rule": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cidr": { + Type: schema.TypeString, + Computed: true, + }, + "egress": { + Type: schema.TypeBool, + Computed: true, + }, + "port_range": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "from": { + Type: schema.TypeInt, + Computed: true, + }, + "to": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, - }, - names.AttrProtocol: { - Type: schema.TypeString, - Computed: true, - }, - "rule_action": { - Type: schema.TypeString, - Computed: true, - }, - "rule_number": { - Type: schema.TypeInt, - Computed: true, + names.AttrProtocol: { + Type: schema.TypeString, + Computed: true, + }, + "rule_action": { + Type: schema.TypeString, + Computed: true, + }, + "rule_number": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, - }, - names.AttrAddress: { - Type: schema.TypeString, - Computed: true, - }, - "addresses": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "attached_to": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + names.AttrAddress: { + Type: schema.TypeString, + Computed: true, + }, + "addresses": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "attached_to": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - names.AttrAvailabilityZones: { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "cidrs": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "classic_load_balancer_listener": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "instance_port": { - Type: schema.TypeInt, - Computed: true, - }, - "load_balancer_port": { - Type: schema.TypeInt, - Computed: true, + names.AttrAvailabilityZones: { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "cidrs": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "classic_load_balancer_listener": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "instance_port": { + Type: schema.TypeInt, + Computed: true, + }, + "load_balancer_port": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, - }, - "component": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "component": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "customer_gateway": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "customer_gateway": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - names.AttrDestination: { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + names.AttrDestination: { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "destination_vpc": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "destination_vpc": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "direction": { - Type: schema.TypeString, - Computed: true, - }, - "elastic_load_balancer_listener": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "direction": { + Type: schema.TypeString, + Computed: true, + }, + "elastic_load_balancer_listener": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "explanation_code": { - Type: schema.TypeString, - Computed: true, - }, - "ingress_route_table": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "explanation_code": { + Type: schema.TypeString, + Computed: true, + }, + "ingress_route_table": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "internet_gateway": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "internet_gateway": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "load_balancer_arn": { - Type: schema.TypeString, - Computed: true, - }, - "load_balancer_listener_port": { - Type: schema.TypeInt, - Computed: true, - }, - "load_balancer_target_group": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "load_balancer_arn": { + Type: schema.TypeString, + Computed: true, + }, + "load_balancer_listener_port": { + Type: schema.TypeInt, + Computed: true, + }, + "load_balancer_target_group": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "load_balancer_target_groups": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "load_balancer_target_groups": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "load_balancer_target_port": { - Type: schema.TypeInt, - Computed: true, - }, - "missing_component": { - Type: schema.TypeString, - Computed: true, - }, - "nat_gateway": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "load_balancer_target_port": { + Type: schema.TypeInt, + Computed: true, + }, + "missing_component": { + Type: schema.TypeString, + Computed: true, + }, + "nat_gateway": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "network_interface": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "network_interface": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "packet_field": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrPort: { - Type: schema.TypeInt, - Computed: true, - }, - "port_ranges": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "from": { - Type: schema.TypeInt, - Computed: true, - }, - "to": { - Type: schema.TypeInt, - Computed: true, + "packet_field": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrPort: { + Type: schema.TypeInt, + Computed: true, + }, + "port_ranges": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "from": { + Type: schema.TypeInt, + Computed: true, + }, + "to": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, - }, - "prefix_list": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "prefix_list": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "protocols": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "route_table": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "protocols": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "route_table": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "route_table_route": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "destination_cidr": { - Type: schema.TypeString, - Computed: true, - }, - "destination_prefix_list_id": { - Type: schema.TypeString, - Computed: true, - }, - "egress_only_internet_gateway_id": { - Type: schema.TypeString, - Computed: true, - }, - "gateway_id": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrInstanceID: { - Type: schema.TypeString, - Computed: true, - }, - "nat_gateway_id": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrNetworkInterfaceID: { - Type: schema.TypeString, - Computed: true, - }, - "origin": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTransitGatewayID: { - Type: schema.TypeString, - Computed: true, - }, - "vpc_peering_connection_id": { - Type: schema.TypeString, - Computed: true, + "route_table_route": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "destination_cidr": { + Type: schema.TypeString, + Computed: true, + }, + "destination_prefix_list_id": { + Type: schema.TypeString, + Computed: true, + }, + "egress_only_internet_gateway_id": { + Type: schema.TypeString, + Computed: true, + }, + "gateway_id": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrInstanceID: { + Type: schema.TypeString, + Computed: true, + }, + "nat_gateway_id": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrNetworkInterfaceID: { + Type: schema.TypeString, + Computed: true, + }, + "origin": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTransitGatewayID: { + Type: schema.TypeString, + Computed: true, + }, + "vpc_peering_connection_id": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "security_group": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "security_group": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "security_group_rule": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "cidr": { - Type: schema.TypeString, - Computed: true, - }, - "direction": { - Type: schema.TypeString, - Computed: true, - }, - "port_range": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "from": { - Type: schema.TypeInt, - Computed: true, - }, - "to": { - Type: schema.TypeInt, - Computed: true, + "security_group_rule": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "cidr": { + Type: schema.TypeString, + Computed: true, + }, + "direction": { + Type: schema.TypeString, + Computed: true, + }, + "port_range": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "from": { + Type: schema.TypeInt, + Computed: true, + }, + "to": { + Type: schema.TypeInt, + Computed: true, + }, }, }, }, - }, - "prefix_list_id": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrProtocol: { - Type: schema.TypeString, - Computed: true, - }, - "security_group_id": { - Type: schema.TypeString, - Computed: true, + "prefix_list_id": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrProtocol: { + Type: schema.TypeString, + Computed: true, + }, + "security_group_id": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - names.AttrSecurityGroups: { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + names.AttrSecurityGroups: { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "source_vpc": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "source_vpc": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - names.AttrState: { - Type: schema.TypeString, - Computed: true, - }, - "subnet": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + names.AttrState: { + Type: schema.TypeString, + Computed: true, + }, + "subnet": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "subnet_route_table": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "subnet_route_table": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "transit_gateway": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "transit_gateway": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "transit_gateway_attachment": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "transit_gateway_attachment": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "transit_gateway_route_table": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "transit_gateway_route_table": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "transit_gateway_route_table_route": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "attachment_id": { - Type: schema.TypeString, - Computed: true, - }, - "destination_cidr": { - Type: schema.TypeString, - Computed: true, - }, - "prefix_list_id": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrResourceID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrResourceType: { - Type: schema.TypeString, - Computed: true, - }, - "route_origin": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrState: { - Type: schema.TypeString, - Computed: true, + "transit_gateway_route_table_route": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "attachment_id": { + Type: schema.TypeString, + Computed: true, + }, + "destination_cidr": { + Type: schema.TypeString, + Computed: true, + }, + "prefix_list_id": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrResourceID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrResourceType: { + Type: schema.TypeString, + Computed: true, + }, + "route_origin": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrState: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "vpc": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "vpc": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "vpc_endpoint": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "vpc_endpoint": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "vpc_peering_connection": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "vpc_peering_connection": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "vpn_connection": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "vpn_connection": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - "vpn_gateway": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrID: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrName: { - Type: schema.TypeString, - Computed: true, + "vpn_gateway": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrID: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrName: { + Type: schema.TypeString, + Computed: true, + }, }, }, }, }, }, - }, + } } func resourceNetworkInsightsAnalysisCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - - conn := meta.(*conns.AWSClient).EC2Conn(ctx) + conn := meta.(*conns.AWSClient).EC2Client(ctx) input := &ec2.StartNetworkInsightsAnalysisInput{ NetworkInsightsPathId: aws.String(d.Get("network_insights_path_id").(string)), - TagSpecifications: getTagSpecificationsIn(ctx, ec2.ResourceTypeNetworkInsightsAnalysis), + TagSpecifications: getTagSpecificationsInV2(ctx, awstypes.ResourceTypeNetworkInsightsAnalysis), } if v, ok := d.GetOk("filter_in_arns"); ok && v.(*schema.Set).Len() > 0 { - input.FilterInArns = flex.ExpandStringSet(v.(*schema.Set)) + input.FilterInArns = flex.ExpandStringValueSet(v.(*schema.Set)) } - log.Printf("[DEBUG] Creating EC2 Network Insights Analysis: %s", input) - output, err := conn.StartNetworkInsightsAnalysisWithContext(ctx, input) + output, err := conn.StartNetworkInsightsAnalysis(ctx, input) if err != nil { return sdkdiag.AppendErrorf(diags, "creating EC2 Network Insights Analysis: %s", err) } - d.SetId(aws.StringValue(output.NetworkInsightsAnalysis.NetworkInsightsAnalysisId)) + d.SetId(aws.ToString(output.NetworkInsightsAnalysis.NetworkInsightsAnalysisId)) if d.Get("wait_for_completion").(bool) { - if _, err := WaitNetworkInsightsAnalysisCreated(ctx, conn, d.Id(), d.Timeout(schema.TimeoutCreate)); err != nil { + if _, err := waitNetworkInsightsAnalysisCreated(ctx, conn, d.Id(), d.Timeout(schema.TimeoutCreate)); err != nil { return sdkdiag.AppendErrorf(diags, "waiting for EC2 Network Insights Analysis (%s) create: %s", d.Id(), err) } } @@ -1439,10 +1444,9 @@ func resourceNetworkInsightsAnalysisCreate(ctx context.Context, d *schema.Resour func resourceNetworkInsightsAnalysisRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics + conn := meta.(*conns.AWSClient).EC2Client(ctx) - conn := meta.(*conns.AWSClient).EC2Conn(ctx) - - output, err := FindNetworkInsightsAnalysisByID(ctx, conn, d.Id()) + output, err := findNetworkInsightsAnalysisByID(ctx, conn, d.Id()) if !d.IsNewResource() && tfresource.NotFound(err) { log.Printf("[WARN] EC2 Network Insights Analysis (%s) not found, removing from state", d.Id()) @@ -1461,7 +1465,7 @@ func resourceNetworkInsightsAnalysisRead(ctx context.Context, d *schema.Resource if err := d.Set("explanations", flattenExplanations(output.Explanations)); err != nil { return sdkdiag.AppendErrorf(diags, "setting explanations: %s", err) } - d.Set("filter_in_arns", aws.StringValueSlice(output.FilterInArns)) + d.Set("filter_in_arns", output.FilterInArns) if err := d.Set("forward_path_components", flattenPathComponents(output.ForwardPathComponents)); err != nil { return sdkdiag.AppendErrorf(diags, "setting forward_path_components: %s", err) } @@ -1475,7 +1479,7 @@ func resourceNetworkInsightsAnalysisRead(ctx context.Context, d *schema.Resource d.Set(names.AttrStatusMessage, output.StatusMessage) d.Set("warning_message", output.WarningMessage) - setTagsOut(ctx, output.Tags) + setTagsOutV2(ctx, output.Tags) return diags } @@ -1487,11 +1491,10 @@ func resourceNetworkInsightsAnalysisUpdate(ctx context.Context, d *schema.Resour func resourceNetworkInsightsAnalysisDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - - conn := meta.(*conns.AWSClient).EC2Conn(ctx) + conn := meta.(*conns.AWSClient).EC2Client(ctx) log.Printf("[DEBUG] Deleting EC2 Network Insights Analysis: %s", d.Id()) - _, err := conn.DeleteNetworkInsightsAnalysisWithContext(ctx, &ec2.DeleteNetworkInsightsAnalysisInput{ + _, err := conn.DeleteNetworkInsightsAnalysis(ctx, &ec2.DeleteNetworkInsightsAnalysisInput{ NetworkInsightsAnalysisId: aws.String(d.Id()), }) @@ -1506,7 +1509,7 @@ func resourceNetworkInsightsAnalysisDelete(ctx context.Context, d *schema.Resour return diags } -func flattenAdditionalDetail(apiObject *ec2.AdditionalDetail) map[string]interface{} { +func flattenAdditionalDetail(apiObject *awstypes.AdditionalDetail) map[string]interface{} { if apiObject == nil { return nil } @@ -1514,7 +1517,7 @@ func flattenAdditionalDetail(apiObject *ec2.AdditionalDetail) map[string]interfa tfMap := map[string]interface{}{} if v := apiObject.AdditionalDetailType; v != nil { - tfMap["additional_detail_type"] = aws.StringValue(v) + tfMap["additional_detail_type"] = aws.ToString(v) } if v := apiObject.Component; v != nil { @@ -1524,7 +1527,7 @@ func flattenAdditionalDetail(apiObject *ec2.AdditionalDetail) map[string]interfa return tfMap } -func flattenAdditionalDetails(apiObjects []*ec2.AdditionalDetail) []interface{} { +func flattenAdditionalDetails(apiObjects []awstypes.AdditionalDetail) []interface{} { if len(apiObjects) == 0 { return nil } @@ -1532,17 +1535,13 @@ func flattenAdditionalDetails(apiObjects []*ec2.AdditionalDetail) []interface{} var tfList []interface{} for _, apiObject := range apiObjects { - if apiObject == nil { - continue - } - - tfList = append(tfList, flattenAdditionalDetail(apiObject)) + tfList = append(tfList, flattenAdditionalDetail(&apiObject)) } return tfList } -func flattenAlternatePathHint(apiObject *ec2.AlternatePathHint) map[string]interface{} { +func flattenAlternatePathHint(apiObject *awstypes.AlternatePathHint) map[string]interface{} { if apiObject == nil { return nil } @@ -1550,17 +1549,17 @@ func flattenAlternatePathHint(apiObject *ec2.AlternatePathHint) map[string]inter tfMap := map[string]interface{}{} if v := apiObject.ComponentArn; v != nil { - tfMap["component_arn"] = aws.StringValue(v) + tfMap["component_arn"] = aws.ToString(v) } if v := apiObject.ComponentId; v != nil { - tfMap["component_id"] = aws.StringValue(v) + tfMap["component_id"] = aws.ToString(v) } return tfMap } -func flattenAlternatePathHints(apiObjects []*ec2.AlternatePathHint) []interface{} { +func flattenAlternatePathHints(apiObjects []awstypes.AlternatePathHint) []interface{} { if len(apiObjects) == 0 { return nil } @@ -1568,17 +1567,13 @@ func flattenAlternatePathHints(apiObjects []*ec2.AlternatePathHint) []interface{ var tfList []interface{} for _, apiObject := range apiObjects { - if apiObject == nil { - continue - } - - tfList = append(tfList, flattenAlternatePathHint(apiObject)) + tfList = append(tfList, flattenAlternatePathHint(&apiObject)) } return tfList } -func flattenAnalysisAclRule(apiObject *ec2.AnalysisAclRule) map[string]interface{} { // nosemgrep:ci.caps2-in-func-name +func flattenAnalysisAclRule(apiObject *awstypes.AnalysisAclRule) map[string]interface{} { // nosemgrep:ci.caps2-in-func-name if apiObject == nil { return nil } @@ -1586,11 +1581,11 @@ func flattenAnalysisAclRule(apiObject *ec2.AnalysisAclRule) map[string]interface tfMap := map[string]interface{}{} if v := apiObject.Cidr; v != nil { - tfMap["cidr"] = aws.StringValue(v) + tfMap["cidr"] = aws.ToString(v) } if v := apiObject.Egress; v != nil { - tfMap["egress"] = aws.BoolValue(v) + tfMap["egress"] = aws.ToBool(v) } if v := apiObject.PortRange; v != nil { @@ -1598,21 +1593,21 @@ func flattenAnalysisAclRule(apiObject *ec2.AnalysisAclRule) map[string]interface } if v := apiObject.Protocol; v != nil { - tfMap[names.AttrProtocol] = aws.StringValue(v) + tfMap[names.AttrProtocol] = aws.ToString(v) } if v := apiObject.RuleAction; v != nil { - tfMap["rule_action"] = aws.StringValue(v) + tfMap["rule_action"] = aws.ToString(v) } if v := apiObject.RuleNumber; v != nil { - tfMap["rule_number"] = aws.Int64Value(v) + tfMap["rule_number"] = aws.ToInt32(v) } return tfMap } -func flattenAnalysisLoadBalancerListener(apiObject *ec2.AnalysisLoadBalancerListener) map[string]interface{} { +func flattenAnalysisLoadBalancerListener(apiObject *awstypes.AnalysisLoadBalancerListener) map[string]interface{} { if apiObject == nil { return nil } @@ -1620,17 +1615,17 @@ func flattenAnalysisLoadBalancerListener(apiObject *ec2.AnalysisLoadBalancerList tfMap := map[string]interface{}{} if v := apiObject.InstancePort; v != nil { - tfMap["instance_port"] = aws.Int64Value(v) + tfMap["instance_port"] = aws.ToInt32(v) } if v := apiObject.LoadBalancerPort; v != nil { - tfMap["load_balancer_port"] = aws.Int64Value(v) + tfMap["load_balancer_port"] = aws.ToInt32(v) } return tfMap } -func flattenAnalysisComponent(apiObject *ec2.AnalysisComponent) map[string]interface{} { +func flattenAnalysisComponent(apiObject *awstypes.AnalysisComponent) map[string]interface{} { if apiObject == nil { return nil } @@ -1638,21 +1633,21 @@ func flattenAnalysisComponent(apiObject *ec2.AnalysisComponent) map[string]inter tfMap := map[string]interface{}{} if v := apiObject.Arn; v != nil { - tfMap[names.AttrARN] = aws.StringValue(v) + tfMap[names.AttrARN] = aws.ToString(v) } if v := apiObject.Id; v != nil { - tfMap[names.AttrID] = aws.StringValue(v) + tfMap[names.AttrID] = aws.ToString(v) } if v := apiObject.Name; v != nil { - tfMap[names.AttrName] = aws.StringValue(v) + tfMap[names.AttrName] = aws.ToString(v) } return tfMap } -func flattenAnalysisComponents(apiObjects []*ec2.AnalysisComponent) []interface{} { +func flattenAnalysisComponents(apiObjects []awstypes.AnalysisComponent) []interface{} { if len(apiObjects) == 0 { return nil } @@ -1660,17 +1655,13 @@ func flattenAnalysisComponents(apiObjects []*ec2.AnalysisComponent) []interface{ var tfList []interface{} for _, apiObject := range apiObjects { - if apiObject == nil { - continue - } - - tfList = append(tfList, flattenAnalysisComponent(apiObject)) + tfList = append(tfList, flattenAnalysisComponent(&apiObject)) } return tfList } -func flattenAnalysisLoadBalancerTarget(apiObject *ec2.AnalysisLoadBalancerTarget) map[string]interface{} { +func flattenAnalysisLoadBalancerTarget(apiObject *awstypes.AnalysisLoadBalancerTarget) map[string]interface{} { if apiObject == nil { return nil } @@ -1678,11 +1669,11 @@ func flattenAnalysisLoadBalancerTarget(apiObject *ec2.AnalysisLoadBalancerTarget tfMap := map[string]interface{}{} if v := apiObject.Address; v != nil { - tfMap[names.AttrAddress] = aws.StringValue(v) + tfMap[names.AttrAddress] = aws.ToString(v) } if v := apiObject.AvailabilityZone; v != nil { - tfMap[names.AttrAvailabilityZone] = aws.StringValue(v) + tfMap[names.AttrAvailabilityZone] = aws.ToString(v) } if v := apiObject.Instance; v != nil { @@ -1690,13 +1681,13 @@ func flattenAnalysisLoadBalancerTarget(apiObject *ec2.AnalysisLoadBalancerTarget } if v := apiObject.Port; v != nil { - tfMap[names.AttrPort] = aws.Int64Value(v) + tfMap[names.AttrPort] = aws.ToInt32(v) } return tfMap } -func flattenAnalysisPacketHeader(apiObject *ec2.AnalysisPacketHeader) map[string]interface{} { +func flattenAnalysisPacketHeader(apiObject *awstypes.AnalysisPacketHeader) map[string]interface{} { if apiObject == nil { return nil } @@ -1704,7 +1695,7 @@ func flattenAnalysisPacketHeader(apiObject *ec2.AnalysisPacketHeader) map[string tfMap := map[string]interface{}{} if v := apiObject.DestinationAddresses; v != nil { - tfMap["destination_addresses"] = aws.StringValueSlice(v) + tfMap["destination_addresses"] = v } if v := apiObject.DestinationPortRanges; v != nil { @@ -1712,11 +1703,11 @@ func flattenAnalysisPacketHeader(apiObject *ec2.AnalysisPacketHeader) map[string } if v := apiObject.Protocol; v != nil { - tfMap[names.AttrProtocol] = aws.StringValue(v) + tfMap[names.AttrProtocol] = aws.ToString(v) } if v := apiObject.SourceAddresses; v != nil { - tfMap["source_addresses"] = aws.StringValueSlice(v) + tfMap["source_addresses"] = v } if v := apiObject.SourcePortRanges; v != nil { @@ -1726,7 +1717,7 @@ func flattenAnalysisPacketHeader(apiObject *ec2.AnalysisPacketHeader) map[string return tfMap } -func flattenAnalysisRouteTableRoute(apiObject *ec2.AnalysisRouteTableRoute) map[string]interface{} { +func flattenAnalysisRouteTableRoute(apiObject *awstypes.AnalysisRouteTableRoute) map[string]interface{} { if apiObject == nil { return nil } @@ -1734,49 +1725,49 @@ func flattenAnalysisRouteTableRoute(apiObject *ec2.AnalysisRouteTableRoute) map[ tfMap := map[string]interface{}{} if v := apiObject.DestinationCidr; v != nil { - tfMap["destination_cidr"] = aws.StringValue(v) + tfMap["destination_cidr"] = aws.ToString(v) } if v := apiObject.DestinationPrefixListId; v != nil { - tfMap["destination_prefix_list_id"] = aws.StringValue(v) + tfMap["destination_prefix_list_id"] = aws.ToString(v) } if v := apiObject.EgressOnlyInternetGatewayId; v != nil { - tfMap["egress_only_internet_gateway_id"] = aws.StringValue(v) + tfMap["egress_only_internet_gateway_id"] = aws.ToString(v) } if v := apiObject.GatewayId; v != nil { - tfMap["gateway_id"] = aws.StringValue(v) + tfMap["gateway_id"] = aws.ToString(v) } if v := apiObject.InstanceId; v != nil { - tfMap[names.AttrInstanceID] = aws.StringValue(v) + tfMap[names.AttrInstanceID] = aws.ToString(v) } if v := apiObject.NatGatewayId; v != nil { - tfMap["nat_gateway_id"] = aws.StringValue(v) + tfMap["nat_gateway_id"] = aws.ToString(v) } if v := apiObject.NetworkInterfaceId; v != nil { - tfMap[names.AttrNetworkInterfaceID] = aws.StringValue(v) + tfMap[names.AttrNetworkInterfaceID] = aws.ToString(v) } if v := apiObject.Origin; v != nil { - tfMap["origin"] = aws.StringValue(v) + tfMap["origin"] = aws.ToString(v) } if v := apiObject.TransitGatewayId; v != nil { - tfMap[names.AttrTransitGatewayID] = aws.StringValue(v) + tfMap[names.AttrTransitGatewayID] = aws.ToString(v) } if v := apiObject.VpcPeeringConnectionId; v != nil { - tfMap["vpc_peering_connection_id"] = aws.StringValue(v) + tfMap["vpc_peering_connection_id"] = aws.ToString(v) } return tfMap } -func flattenAnalysisSecurityGroupRule(apiObject *ec2.AnalysisSecurityGroupRule) map[string]interface{} { +func flattenAnalysisSecurityGroupRule(apiObject *awstypes.AnalysisSecurityGroupRule) map[string]interface{} { if apiObject == nil { return nil } @@ -1784,7 +1775,7 @@ func flattenAnalysisSecurityGroupRule(apiObject *ec2.AnalysisSecurityGroupRule) tfMap := map[string]interface{}{} if v := apiObject.Cidr; v != nil { - tfMap["cidr"] = aws.StringValue(v) + tfMap["cidr"] = aws.ToString(v) } if v := apiObject.PortRange; v != nil { @@ -1792,21 +1783,21 @@ func flattenAnalysisSecurityGroupRule(apiObject *ec2.AnalysisSecurityGroupRule) } if v := apiObject.PrefixListId; v != nil { - tfMap["prefix_list_id"] = aws.StringValue(v) + tfMap["prefix_list_id"] = aws.ToString(v) } if v := apiObject.Protocol; v != nil { - tfMap[names.AttrProtocol] = aws.StringValue(v) + tfMap[names.AttrProtocol] = aws.ToString(v) } if v := apiObject.SecurityGroupId; v != nil { - tfMap["security_group_id"] = aws.StringValue(v) + tfMap["security_group_id"] = aws.ToString(v) } return tfMap } -func flattenExplanation(apiObject *ec2.Explanation) map[string]interface{} { +func flattenExplanation(apiObject *awstypes.Explanation) map[string]interface{} { if apiObject == nil { return nil } @@ -1822,11 +1813,11 @@ func flattenExplanation(apiObject *ec2.Explanation) map[string]interface{} { } if v := apiObject.Address; v != nil { - tfMap[names.AttrAddress] = aws.StringValue(v) + tfMap[names.AttrAddress] = aws.ToString(v) } if v := apiObject.Addresses; v != nil { - tfMap["addresses"] = aws.StringValueSlice(v) + tfMap["addresses"] = v } if v := apiObject.AttachedTo; v != nil { @@ -1834,11 +1825,11 @@ func flattenExplanation(apiObject *ec2.Explanation) map[string]interface{} { } if v := apiObject.AvailabilityZones; v != nil { - tfMap[names.AttrAvailabilityZones] = aws.StringValueSlice(v) + tfMap[names.AttrAvailabilityZones] = v } if v := apiObject.Cidrs; v != nil { - tfMap["cidrs"] = aws.StringValueSlice(v) + tfMap["cidrs"] = v } if v := apiObject.ClassicLoadBalancerListener; v != nil { @@ -1862,7 +1853,7 @@ func flattenExplanation(apiObject *ec2.Explanation) map[string]interface{} { } if v := apiObject.Direction; v != nil { - tfMap["direction"] = aws.StringValue(v) + tfMap["direction"] = aws.ToString(v) } if v := apiObject.ElasticLoadBalancerListener; v != nil { @@ -1870,7 +1861,7 @@ func flattenExplanation(apiObject *ec2.Explanation) map[string]interface{} { } if v := apiObject.ExplanationCode; v != nil { - tfMap["explanation_code"] = aws.StringValue(v) + tfMap["explanation_code"] = aws.ToString(v) } if v := apiObject.IngressRouteTable; v != nil { @@ -1882,11 +1873,11 @@ func flattenExplanation(apiObject *ec2.Explanation) map[string]interface{} { } if v := apiObject.LoadBalancerArn; v != nil { - tfMap["load_balancer_arn"] = aws.StringValue(v) + tfMap["load_balancer_arn"] = aws.ToString(v) } if v := apiObject.LoadBalancerListenerPort; v != nil { - tfMap["load_balancer_listener_port"] = aws.Int64Value(v) + tfMap["load_balancer_listener_port"] = aws.ToInt32(v) } if v := apiObject.LoadBalancerTarget; v != nil { @@ -1902,11 +1893,11 @@ func flattenExplanation(apiObject *ec2.Explanation) map[string]interface{} { } if v := apiObject.LoadBalancerTargetPort; v != nil { - tfMap["load_balancer_target_port"] = aws.Int64Value(v) + tfMap["load_balancer_target_port"] = aws.ToInt32(v) } if v := apiObject.MissingComponent; v != nil { - tfMap["missing_component"] = aws.StringValue(v) + tfMap["missing_component"] = aws.ToString(v) } if v := apiObject.NatGateway; v != nil { @@ -1918,11 +1909,11 @@ func flattenExplanation(apiObject *ec2.Explanation) map[string]interface{} { } if v := apiObject.PacketField; v != nil { - tfMap["packet_field"] = aws.StringValue(v) + tfMap["packet_field"] = aws.ToString(v) } if v := apiObject.Port; v != nil { - tfMap[names.AttrPort] = aws.Int64Value(v) + tfMap[names.AttrPort] = aws.ToInt32(v) } if v := apiObject.PortRanges; v != nil { @@ -1934,7 +1925,7 @@ func flattenExplanation(apiObject *ec2.Explanation) map[string]interface{} { } if v := apiObject.Protocols; v != nil { - tfMap["protocols"] = aws.StringValueSlice(v) + tfMap["protocols"] = v } if v := apiObject.RouteTable; v != nil { @@ -1962,7 +1953,7 @@ func flattenExplanation(apiObject *ec2.Explanation) map[string]interface{} { } if v := apiObject.State; v != nil { - tfMap[names.AttrState] = aws.StringValue(v) + tfMap[names.AttrState] = aws.ToString(v) } if v := apiObject.Subnet; v != nil { @@ -2012,7 +2003,7 @@ func flattenExplanation(apiObject *ec2.Explanation) map[string]interface{} { return tfMap } -func flattenExplanations(apiObjects []*ec2.Explanation) []interface{} { +func flattenExplanations(apiObjects []awstypes.Explanation) []interface{} { if len(apiObjects) == 0 { return nil } @@ -2020,17 +2011,13 @@ func flattenExplanations(apiObjects []*ec2.Explanation) []interface{} { var tfList []interface{} for _, apiObject := range apiObjects { - if apiObject == nil { - continue - } - - tfList = append(tfList, flattenExplanation(apiObject)) + tfList = append(tfList, flattenExplanation(&apiObject)) } return tfList } -func flattenPathComponent(apiObject *ec2.PathComponent) map[string]interface{} { +func flattenPathComponent(apiObject *awstypes.PathComponent) map[string]interface{} { if apiObject == nil { return nil } @@ -2070,7 +2057,7 @@ func flattenPathComponent(apiObject *ec2.PathComponent) map[string]interface{} { } if v := apiObject.SequenceNumber; v != nil { - tfMap["sequence_number"] = aws.Int64Value(v) + tfMap["sequence_number"] = aws.ToInt32(v) } if v := apiObject.SourceVpc; v != nil { @@ -2096,7 +2083,7 @@ func flattenPathComponent(apiObject *ec2.PathComponent) map[string]interface{} { return tfMap } -func flattenPathComponents(apiObjects []*ec2.PathComponent) []interface{} { +func flattenPathComponents(apiObjects []awstypes.PathComponent) []interface{} { if len(apiObjects) == 0 { return nil } @@ -2104,17 +2091,13 @@ func flattenPathComponents(apiObjects []*ec2.PathComponent) []interface{} { var tfList []interface{} for _, apiObject := range apiObjects { - if apiObject == nil { - continue - } - - tfList = append(tfList, flattenPathComponent(apiObject)) + tfList = append(tfList, flattenPathComponent(&apiObject)) } return tfList } -func flattenPortRange(apiObject *ec2.PortRange) map[string]interface{} { +func flattenPortRange(apiObject *awstypes.PortRange) map[string]interface{} { if apiObject == nil { return nil } @@ -2122,17 +2105,17 @@ func flattenPortRange(apiObject *ec2.PortRange) map[string]interface{} { tfMap := map[string]interface{}{} if v := apiObject.From; v != nil { - tfMap["from"] = aws.Int64Value(v) + tfMap["from"] = aws.ToInt32(v) } if v := apiObject.To; v != nil { - tfMap["to"] = aws.Int64Value(v) + tfMap["to"] = aws.ToInt32(v) } return tfMap } -func flattenPortRanges(apiObjects []*ec2.PortRange) []interface{} { +func flattenPortRanges(apiObjects []awstypes.PortRange) []interface{} { if len(apiObjects) == 0 { return nil } @@ -2140,17 +2123,13 @@ func flattenPortRanges(apiObjects []*ec2.PortRange) []interface{} { var tfList []interface{} for _, apiObject := range apiObjects { - if apiObject == nil { - continue - } - - tfList = append(tfList, flattenPortRange(apiObject)) + tfList = append(tfList, flattenPortRange(&apiObject)) } return tfList } -func flattenTransitGatewayRouteTableRoute(apiObject *ec2.TransitGatewayRouteTableRoute) map[string]interface{} { +func flattenTransitGatewayRouteTableRoute(apiObject *awstypes.TransitGatewayRouteTableRoute) map[string]interface{} { if apiObject == nil { return nil } @@ -2158,31 +2137,31 @@ func flattenTransitGatewayRouteTableRoute(apiObject *ec2.TransitGatewayRouteTabl tfMap := map[string]interface{}{} if v := apiObject.AttachmentId; v != nil { - tfMap["attachment_id"] = aws.StringValue(v) + tfMap["attachment_id"] = aws.ToString(v) } if v := apiObject.DestinationCidr; v != nil { - tfMap["destination_cidr"] = aws.StringValue(v) + tfMap["destination_cidr"] = aws.ToString(v) } if v := apiObject.PrefixListId; v != nil { - tfMap["prefix_list_id"] = aws.StringValue(v) + tfMap["prefix_list_id"] = aws.ToString(v) } if v := apiObject.ResourceId; v != nil { - tfMap[names.AttrResourceID] = aws.StringValue(v) + tfMap[names.AttrResourceID] = aws.ToString(v) } if v := apiObject.ResourceType; v != nil { - tfMap[names.AttrResourceType] = aws.StringValue(v) + tfMap[names.AttrResourceType] = aws.ToString(v) } if v := apiObject.RouteOrigin; v != nil { - tfMap["route_origin"] = aws.StringValue(v) + tfMap["route_origin"] = aws.ToString(v) } if v := apiObject.State; v != nil { - tfMap[names.AttrState] = aws.StringValue(v) + tfMap[names.AttrState] = aws.ToString(v) } return tfMap diff --git a/internal/service/ec2/vpc_network_insights_analysis_data_source.go b/internal/service/ec2/vpc_network_insights_analysis_data_source.go index 9bb94c04c1e..6c6959e3772 100644 --- a/internal/service/ec2/vpc_network_insights_analysis_data_source.go +++ b/internal/service/ec2/vpc_network_insights_analysis_data_source.go @@ -7,8 +7,8 @@ import ( "context" "time" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/ec2" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/ec2" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -18,88 +18,90 @@ import ( "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKDataSource("aws_ec2_network_insights_analysis") -func DataSourceNetworkInsightsAnalysis() *schema.Resource { +// @SDKDataSource("aws_ec2_network_insights_analysis", name="Network Insights Analysis") +// @Tags +// @Testing(tagsTest=false) +func dataSourceNetworkInsightsAnalysis() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceNetworkInsightsAnalysisRead, - Schema: map[string]*schema.Schema{ - "alternate_path_hints": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "component_arn": { - Type: schema.TypeString, - Computed: true, - }, - "component_id": { - Type: schema.TypeString, - Computed: true, + SchemaFunc: func() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "alternate_path_hints": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "component_arn": { + Type: schema.TypeString, + Computed: true, + }, + "component_id": { + Type: schema.TypeString, + Computed: true, + }, }, }, }, - }, - names.AttrARN: { - Type: schema.TypeString, - Computed: true, - }, - "explanations": networkInsightsAnalysisExplanationsSchema, - names.AttrFilter: customFiltersSchema(), - "filter_in_arns": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Schema{Type: schema.TypeString}, - }, - "forward_path_components": networkInsightsAnalysisPathComponentsSchema, - "network_insights_analysis_id": { - Type: schema.TypeString, - Optional: true, - Computed: true, - }, - "network_insights_path_id": { - Type: schema.TypeString, - Computed: true, - }, - "path_found": { - Type: schema.TypeBool, - Computed: true, - }, - "return_path_components": networkInsightsAnalysisPathComponentsSchema, - "start_date": { - Type: schema.TypeString, - Computed: true, - }, - names.AttrStatus: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrStatusMessage: { - Type: schema.TypeString, - Computed: true, - }, - names.AttrTags: tftags.TagsSchemaComputed(), - "warning_message": { - Type: schema.TypeString, - Computed: true, - }, + names.AttrARN: { + Type: schema.TypeString, + Computed: true, + }, + "explanations": networkInsightsAnalysisExplanationsSchema(), + names.AttrFilter: customFiltersSchema(), + "filter_in_arns": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Schema{Type: schema.TypeString}, + }, + "forward_path_components": networkInsightsAnalysisPathComponentsSchema(), + "network_insights_analysis_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "network_insights_path_id": { + Type: schema.TypeString, + Computed: true, + }, + "path_found": { + Type: schema.TypeBool, + Computed: true, + }, + "return_path_components": networkInsightsAnalysisPathComponentsSchema(), + "start_date": { + Type: schema.TypeString, + Computed: true, + }, + names.AttrStatus: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrStatusMessage: { + Type: schema.TypeString, + Computed: true, + }, + names.AttrTags: tftags.TagsSchemaComputed(), + "warning_message": { + Type: schema.TypeString, + Computed: true, + }, + } }, } } func dataSourceNetworkInsightsAnalysisRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - - conn := meta.(*conns.AWSClient).EC2Conn(ctx) - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig + conn := meta.(*conns.AWSClient).EC2Client(ctx) input := &ec2.DescribeNetworkInsightsAnalysesInput{} if v, ok := d.GetOk("network_insights_analysis_id"); ok { - input.NetworkInsightsAnalysisIds = aws.StringSlice([]string{v.(string)}) + input.NetworkInsightsAnalysisIds = []string{v.(string)} } - input.Filters = append(input.Filters, newCustomFilterList( + input.Filters = append(input.Filters, newCustomFilterListV2( d.Get(names.AttrFilter).(*schema.Set), )...) @@ -108,13 +110,13 @@ func dataSourceNetworkInsightsAnalysisRead(ctx context.Context, d *schema.Resour input.Filters = nil } - output, err := FindNetworkInsightsAnalysis(ctx, conn, input) + output, err := findNetworkInsightsAnalysis(ctx, conn, input) if err != nil { return sdkdiag.AppendFromErr(diags, tfresource.SingularDataSourceFindError("EC2 Network Insights Analysis", err)) } - networkInsightsAnalysisID := aws.StringValue(output.NetworkInsightsAnalysisId) + networkInsightsAnalysisID := aws.ToString(output.NetworkInsightsAnalysisId) d.SetId(networkInsightsAnalysisID) if err := d.Set("alternate_path_hints", flattenAlternatePathHints(output.AlternatePathHints)); err != nil { return sdkdiag.AppendErrorf(diags, "setting alternate_path_hints: %s", err) @@ -123,7 +125,7 @@ func dataSourceNetworkInsightsAnalysisRead(ctx context.Context, d *schema.Resour if err := d.Set("explanations", flattenExplanations(output.Explanations)); err != nil { return sdkdiag.AppendErrorf(diags, "setting explanations: %s", err) } - d.Set("filter_in_arns", aws.StringValueSlice(output.FilterInArns)) + d.Set("filter_in_arns", output.FilterInArns) if err := d.Set("forward_path_components", flattenPathComponents(output.ForwardPathComponents)); err != nil { return sdkdiag.AppendErrorf(diags, "setting forward_path_components: %s", err) } @@ -138,9 +140,7 @@ func dataSourceNetworkInsightsAnalysisRead(ctx context.Context, d *schema.Resour d.Set(names.AttrStatusMessage, output.StatusMessage) d.Set("warning_message", output.WarningMessage) - if err := d.Set(names.AttrTags, KeyValueTags(ctx, output.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } + setTagsOutV2(ctx, output.Tags) return diags } diff --git a/internal/service/ec2/vpc_network_insights_analysis_test.go b/internal/service/ec2/vpc_network_insights_analysis_test.go index 48747e75615..9725374c1a1 100644 --- a/internal/service/ec2/vpc_network_insights_analysis_test.go +++ b/internal/service/ec2/vpc_network_insights_analysis_test.go @@ -195,11 +195,7 @@ func testAccCheckNetworkInsightsAnalysisExists(ctx context.Context, n string) re return fmt.Errorf("Not found: %s", n) } - if rs.Primary.ID == "" { - return fmt.Errorf("No EC2 Network Insights Analysis ID is set") - } - - conn := acctest.Provider.Meta().(*conns.AWSClient).EC2Conn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).EC2Client(ctx) _, err := tfec2.FindNetworkInsightsAnalysisByID(ctx, conn, rs.Primary.ID) @@ -209,7 +205,7 @@ func testAccCheckNetworkInsightsAnalysisExists(ctx context.Context, n string) re func testAccCheckNetworkInsightsAnalysisDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).EC2Conn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).EC2Client(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_ec2_network_insights_analysis" { diff --git a/internal/service/ec2/vpc_network_insights_path.go b/internal/service/ec2/vpc_network_insights_path.go index 8392287c25b..94a4259cf78 100644 --- a/internal/service/ec2/vpc_network_insights_path.go +++ b/internal/service/ec2/vpc_network_insights_path.go @@ -8,14 +8,15 @@ import ( "log" "strings" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/ec2" + awstypes "github.com/aws/aws-sdk-go-v2/service/ec2/types" + "github.com/hashicorp/aws-sdk-go-base/v2/tfawserr" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/id" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/enum" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" @@ -26,7 +27,7 @@ import ( // @SDKResource("aws_ec2_network_insights_path", name="Network Insights Path") // @Tags(identifierAttribute="id") // @Testing(tagsTest=false) -func ResourceNetworkInsightsPath() *schema.Resource { +func resourceNetworkInsightsPath() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceNetworkInsightsPathCreate, ReadWithoutTimeout: resourceNetworkInsightsPathRead, @@ -48,7 +49,7 @@ func ResourceNetworkInsightsPath() *schema.Resource { }, names.AttrDestination: { Type: schema.TypeString, - Required: true, + Optional: true, ForceNew: true, DiffSuppressFunc: suppressEquivalentIDOrARN, }, @@ -63,10 +64,10 @@ func ResourceNetworkInsightsPath() *schema.Resource { ForceNew: true, }, names.AttrProtocol: { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(ec2.Protocol_Values(), false), + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateDiagFunc: enum.Validate[awstypes.Protocol](), }, names.AttrSource: { Type: schema.TypeString, @@ -93,15 +94,17 @@ func ResourceNetworkInsightsPath() *schema.Resource { func resourceNetworkInsightsPathCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - - conn := meta.(*conns.AWSClient).EC2Conn(ctx) + conn := meta.(*conns.AWSClient).EC2Client(ctx) input := &ec2.CreateNetworkInsightsPathInput{ ClientToken: aws.String(id.UniqueId()), - Destination: aws.String(d.Get(names.AttrDestination).(string)), - Protocol: aws.String(d.Get(names.AttrProtocol).(string)), + Protocol: awstypes.Protocol(d.Get(names.AttrProtocol).(string)), Source: aws.String(d.Get(names.AttrSource).(string)), - TagSpecifications: getTagSpecificationsIn(ctx, ec2.ResourceTypeNetworkInsightsPath), + TagSpecifications: getTagSpecificationsInV2(ctx, awstypes.ResourceTypeNetworkInsightsPath), + } + + if v, ok := d.GetOk(names.AttrDestination); ok { + input.Destination = aws.String(v.(string)) } if v, ok := d.GetOk("destination_ip"); ok { @@ -109,30 +112,29 @@ func resourceNetworkInsightsPathCreate(ctx context.Context, d *schema.ResourceDa } if v, ok := d.GetOk("destination_port"); ok { - input.DestinationPort = aws.Int64(int64(v.(int))) + input.DestinationPort = aws.Int32(int32(v.(int))) } if v, ok := d.GetOk("source_ip"); ok { input.SourceIp = aws.String(v.(string)) } - output, err := conn.CreateNetworkInsightsPathWithContext(ctx, input) + output, err := conn.CreateNetworkInsightsPath(ctx, input) if err != nil { return sdkdiag.AppendErrorf(diags, "creating EC2 Network Insights Path: %s", err) } - d.SetId(aws.StringValue(output.NetworkInsightsPath.NetworkInsightsPathId)) + d.SetId(aws.ToString(output.NetworkInsightsPath.NetworkInsightsPathId)) return append(diags, resourceNetworkInsightsPathRead(ctx, d, meta)...) } func resourceNetworkInsightsPathRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics + conn := meta.(*conns.AWSClient).EC2Client(ctx) - conn := meta.(*conns.AWSClient).EC2Conn(ctx) - - nip, err := FindNetworkInsightsPathByID(ctx, conn, d.Id()) + nip, err := findNetworkInsightsPathByID(ctx, conn, d.Id()) if !d.IsNewResource() && tfresource.NotFound(err) { log.Printf("[WARN] EC2 Network Insights Path %s not found, removing from state", d.Id()) @@ -154,7 +156,7 @@ func resourceNetworkInsightsPathRead(ctx context.Context, d *schema.ResourceData d.Set("source_arn", nip.SourceArn) d.Set("source_ip", nip.SourceIp) - setTagsOut(ctx, nip.Tags) + setTagsOutV2(ctx, nip.Tags) return diags } @@ -166,12 +168,11 @@ func resourceNetworkInsightsPathUpdate(ctx context.Context, d *schema.ResourceDa func resourceNetworkInsightsPathDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - - conn := meta.(*conns.AWSClient).EC2Conn(ctx) + conn := meta.(*conns.AWSClient).EC2Client(ctx) log.Printf("[DEBUG] Deleting EC2 Network Insights Path: %s", d.Id()) _, err := tfresource.RetryWhenAWSErrCodeEquals(ctx, ec2PropagationTimeout, func() (interface{}, error) { - return conn.DeleteNetworkInsightsPathWithContext(ctx, &ec2.DeleteNetworkInsightsPathInput{ + return conn.DeleteNetworkInsightsPath(ctx, &ec2.DeleteNetworkInsightsPathInput{ NetworkInsightsPathId: aws.String(d.Id()), }) }, errCodeAnalysisExistsForNetworkInsightsPath) diff --git a/internal/service/ec2/vpc_network_insights_path_data_source.go b/internal/service/ec2/vpc_network_insights_path_data_source.go index 464ba0fee48..c1f503d67f9 100644 --- a/internal/service/ec2/vpc_network_insights_path_data_source.go +++ b/internal/service/ec2/vpc_network_insights_path_data_source.go @@ -6,8 +6,8 @@ package ec2 import ( "context" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/ec2" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/ec2" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -17,8 +17,10 @@ import ( "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKDataSource("aws_ec2_network_insights_path") -func DataSourceNetworkInsightsPath() *schema.Resource { +// @SDKDataSource("aws_ec2_network_insights_path", name="Network Insights Path") +// @Tags +// @Testing(tagsTest=false) +func dataSourceNetworkInsightsPath() *schema.Resource { return &schema.Resource{ ReadWithoutTimeout: dataSourceNetworkInsightsPathRead, @@ -72,17 +74,15 @@ func DataSourceNetworkInsightsPath() *schema.Resource { func dataSourceNetworkInsightsPathRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - - conn := meta.(*conns.AWSClient).EC2Conn(ctx) - ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig + conn := meta.(*conns.AWSClient).EC2Client(ctx) input := &ec2.DescribeNetworkInsightsPathsInput{} if v, ok := d.GetOk("network_insights_path_id"); ok { - input.NetworkInsightsPathIds = aws.StringSlice([]string{v.(string)}) + input.NetworkInsightsPathIds = []string{v.(string)} } - input.Filters = append(input.Filters, newCustomFilterList( + input.Filters = append(input.Filters, newCustomFilterListV2( d.Get(names.AttrFilter).(*schema.Set), )...) @@ -91,13 +91,13 @@ func dataSourceNetworkInsightsPathRead(ctx context.Context, d *schema.ResourceDa input.Filters = nil } - nip, err := FindNetworkInsightsPath(ctx, conn, input) + nip, err := findNetworkInsightsPath(ctx, conn, input) if err != nil { return sdkdiag.AppendFromErr(diags, tfresource.SingularDataSourceFindError("EC2 Network Insights Path", err)) } - networkInsightsPathID := aws.StringValue(nip.NetworkInsightsPathId) + networkInsightsPathID := aws.ToString(nip.NetworkInsightsPathId) d.SetId(networkInsightsPathID) d.Set(names.AttrARN, nip.NetworkInsightsPathArn) d.Set(names.AttrDestination, nip.Destination) @@ -110,9 +110,7 @@ func dataSourceNetworkInsightsPathRead(ctx context.Context, d *schema.ResourceDa d.Set("source_arn", nip.SourceArn) d.Set("source_ip", nip.SourceIp) - if err := d.Set(names.AttrTags, KeyValueTags(ctx, nip.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { - return sdkdiag.AppendErrorf(diags, "setting tags: %s", err) - } + setTagsOutV2(ctx, nip.Tags) return diags } diff --git a/internal/service/ec2/vpc_network_insights_path_test.go b/internal/service/ec2/vpc_network_insights_path_test.go index 2ad8f02b262..1b78c002af3 100644 --- a/internal/service/ec2/vpc_network_insights_path_test.go +++ b/internal/service/ec2/vpc_network_insights_path_test.go @@ -262,11 +262,7 @@ func testAccCheckNetworkInsightsPathExists(ctx context.Context, n string) resour return fmt.Errorf("Not found: %s", n) } - if rs.Primary.ID == "" { - return fmt.Errorf("No EC2 Network Insights Path ID is set") - } - - conn := acctest.Provider.Meta().(*conns.AWSClient).EC2Conn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).EC2Client(ctx) _, err := tfec2.FindNetworkInsightsPathByID(ctx, conn, rs.Primary.ID) @@ -276,7 +272,7 @@ func testAccCheckNetworkInsightsPathExists(ctx context.Context, n string) resour func testAccCheckNetworkInsightsPathDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).EC2Conn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).EC2Client(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_ec2_network_insights_path" { diff --git a/internal/service/ec2/wait.go b/internal/service/ec2/wait.go index 24b7d30dac2..2c9087ec5a0 100644 --- a/internal/service/ec2/wait.go +++ b/internal/service/ec2/wait.go @@ -692,27 +692,6 @@ func WaitManagedPrefixListDeleted(ctx context.Context, conn *ec2.EC2, id string) return nil, err } -func WaitNetworkInsightsAnalysisCreated(ctx context.Context, conn *ec2.EC2, id string, timeout time.Duration) (*ec2.NetworkInsightsAnalysis, error) { - stateConf := &retry.StateChangeConf{ - Pending: []string{ec2.AnalysisStatusRunning}, - Target: []string{ec2.AnalysisStatusSucceeded}, - Timeout: timeout, - Refresh: StatusNetworkInsightsAnalysis(ctx, conn, id), - Delay: 10 * time.Second, - MinTimeout: 5 * time.Second, - } - - outputRaw, err := stateConf.WaitForStateContext(ctx) - - if output, ok := outputRaw.(*ec2.NetworkInsightsAnalysis); ok { - tfresource.SetLastError(err, errors.New(aws.StringValue(output.StatusMessage))) - - return output, err - } - - return nil, err -} - const ( networkInterfaceAttachedTimeout = 5 * time.Minute NetworkInterfaceDetachedTimeout = 10 * time.Minute diff --git a/internal/service/ec2/waitv2.go b/internal/service/ec2/waitv2.go index bd9cb5e2242..9f15a048b62 100644 --- a/internal/service/ec2/waitv2.go +++ b/internal/service/ec2/waitv2.go @@ -2589,3 +2589,24 @@ func waitFastSnapshotRestoreDeleted(ctx context.Context, conn *ec2.Client, avail return nil, err } + +func waitNetworkInsightsAnalysisCreated(ctx context.Context, conn *ec2.Client, id string, timeout time.Duration) (*awstypes.NetworkInsightsAnalysis, error) { + stateConf := &retry.StateChangeConf{ + Pending: enum.Slice(awstypes.AnalysisStatusRunning), + Target: enum.Slice(awstypes.AnalysisStatusSucceeded), + Timeout: timeout, + Refresh: statusNetworkInsightsAnalysis(ctx, conn, id), + Delay: 10 * time.Second, + MinTimeout: 5 * time.Second, + } + + outputRaw, err := stateConf.WaitForStateContext(ctx) + + if output, ok := outputRaw.(*awstypes.NetworkInsightsAnalysis); ok { + tfresource.SetLastError(err, errors.New(aws.ToString(output.StatusMessage))) + + return output, err + } + + return nil, err +} diff --git a/internal/service/rum/app_monitor.go b/internal/service/rum/app_monitor.go index 6e08f781085..f634adb088c 100644 --- a/internal/service/rum/app_monitor.go +++ b/internal/service/rum/app_monitor.go @@ -5,18 +5,19 @@ package rum import ( "context" - "fmt" "log" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/arn" - "github.com/aws/aws-sdk-go/service/cloudwatchrum" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/aws/arn" + "github.com/aws/aws-sdk-go-v2/service/rum" + awstypes "github.com/aws/aws-sdk-go-v2/service/rum/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/enum" + "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/flex" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" @@ -27,7 +28,7 @@ import ( // @SDKResource("aws_rum_app_monitor", name="App Monitor") // @Tags(identifierAttribute="arn") -func ResourceAppMonitor() *schema.Resource { +func resourceAppMonitor() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceAppMonitorCreate, ReadWithoutTimeout: resourceAppMonitorRead, @@ -91,8 +92,8 @@ func ResourceAppMonitor() *schema.Resource { Type: schema.TypeSet, Optional: true, Elem: &schema.Schema{ - Type: schema.TypeString, - ValidateFunc: validation.StringInSlice(cloudwatchrum.Telemetry_Values(), false), + Type: schema.TypeString, + ValidateDiagFunc: enum.Validate[awstypes.Telemetry](), }, }, }, @@ -114,10 +115,10 @@ func ResourceAppMonitor() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ names.AttrStatus: { - Type: schema.TypeString, - Optional: true, - Default: cloudwatchrum.CustomEventsStatusDisabled, - ValidateFunc: validation.StringInSlice(cloudwatchrum.CustomEventsStatus_Values(), false), + Type: schema.TypeString, + Optional: true, + Default: awstypes.CustomEventsStatusDisabled, + ValidateDiagFunc: enum.Validate[awstypes.CustomEventsStatus](), }, }, }, @@ -145,16 +146,17 @@ func ResourceAppMonitor() *schema.Resource { names.AttrTags: tftags.TagsSchema(), names.AttrTagsAll: tftags.TagsSchemaComputed(), }, + CustomizeDiff: verify.SetTagsDiff, } } func resourceAppMonitorCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).RUMConn(ctx) + conn := meta.(*conns.AWSClient).RUMClient(ctx) name := d.Get(names.AttrName).(string) - input := &cloudwatchrum.CreateAppMonitorInput{ + input := &rum.CreateAppMonitorInput{ Name: aws.String(name), CwLogEnabled: aws.Bool(d.Get("cw_log_enabled").(bool)), Domain: aws.String(d.Get(names.AttrDomain).(string)), @@ -169,7 +171,7 @@ func resourceAppMonitorCreate(ctx context.Context, d *schema.ResourceData, meta input.CustomEvents = expandCustomEvents(v.([]interface{})[0].(map[string]interface{})) } - _, err := conn.CreateAppMonitorWithContext(ctx, input) + _, err := conn.CreateAppMonitor(ctx, input) if err != nil { return sdkdiag.AppendErrorf(diags, "creating CloudWatch RUM App Monitor (%s): %s", name, err) @@ -182,9 +184,9 @@ func resourceAppMonitorCreate(ctx context.Context, d *schema.ResourceData, meta func resourceAppMonitorRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).RUMConn(ctx) + conn := meta.(*conns.AWSClient).RUMClient(ctx) - appMon, err := FindAppMonitorByName(ctx, conn, d.Id()) + appMon, err := findAppMonitorByName(ctx, conn, d.Id()) if !d.IsNewResource() && tfresource.NotFound(err) { log.Printf("[WARN] CloudWatch RUM App Monitor %s not found, removing from state", d.Id()) @@ -205,18 +207,19 @@ func resourceAppMonitorRead(ctx context.Context, d *schema.ResourceData, meta in } d.Set("app_monitor_id", appMon.Id) + name := aws.ToString(appMon.Name) arn := arn.ARN{ - AccountID: meta.(*conns.AWSClient).AccountID, Partition: meta.(*conns.AWSClient).Partition, - Region: meta.(*conns.AWSClient).Region, - Resource: fmt.Sprintf("appmonitor/%s", aws.StringValue(appMon.Name)), Service: "rum", + Region: meta.(*conns.AWSClient).Region, + AccountID: meta.(*conns.AWSClient).AccountID, + Resource: "appmonitor/" + name, }.String() d.Set(names.AttrARN, arn) d.Set("cw_log_enabled", appMon.DataStorage.CwLog.CwLogEnabled) d.Set("cw_log_group", appMon.DataStorage.CwLog.CwLogGroup) d.Set(names.AttrDomain, appMon.Domain) - d.Set(names.AttrName, appMon.Name) + d.Set(names.AttrName, name) setTagsOut(ctx, appMon.Tags) @@ -225,10 +228,10 @@ func resourceAppMonitorRead(ctx context.Context, d *schema.ResourceData, meta in func resourceAppMonitorUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).RUMConn(ctx) + conn := meta.(*conns.AWSClient).RUMClient(ctx) if d.HasChangesExcept(names.AttrTags, names.AttrTagsAll) { - input := &cloudwatchrum.UpdateAppMonitorInput{ + input := &rum.UpdateAppMonitorInput{ Name: aws.String(d.Id()), } @@ -248,7 +251,7 @@ func resourceAppMonitorUpdate(ctx context.Context, d *schema.ResourceData, meta input.Domain = aws.String(d.Get(names.AttrDomain).(string)) } - _, err := conn.UpdateAppMonitorWithContext(ctx, input) + _, err := conn.UpdateAppMonitor(ctx, input) if err != nil { return sdkdiag.AppendErrorf(diags, "updating CloudWatch RUM App Monitor (%s): %s", d.Id(), err) @@ -260,14 +263,14 @@ func resourceAppMonitorUpdate(ctx context.Context, d *schema.ResourceData, meta func resourceAppMonitorDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).RUMConn(ctx) + conn := meta.(*conns.AWSClient).RUMClient(ctx) log.Printf("[DEBUG] Deleting CloudWatch RUM App Monitor: %s", d.Id()) - _, err := conn.DeleteAppMonitorWithContext(ctx, &cloudwatchrum.DeleteAppMonitorInput{ + _, err := conn.DeleteAppMonitor(ctx, &rum.DeleteAppMonitorInput{ Name: aws.String(d.Id()), }) - if tfawserr.ErrCodeEquals(err, cloudwatchrum.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { return diags } @@ -278,14 +281,14 @@ func resourceAppMonitorDelete(ctx context.Context, d *schema.ResourceData, meta return diags } -func FindAppMonitorByName(ctx context.Context, conn *cloudwatchrum.CloudWatchRUM, name string) (*cloudwatchrum.AppMonitor, error) { - input := &cloudwatchrum.GetAppMonitorInput{ +func findAppMonitorByName(ctx context.Context, conn *rum.Client, name string) (*awstypes.AppMonitor, error) { + input := &rum.GetAppMonitorInput{ Name: aws.String(name), } - output, err := conn.GetAppMonitorWithContext(ctx, input) + output, err := conn.GetAppMonitor(ctx, input) - if tfawserr.ErrCodeEquals(err, cloudwatchrum.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { return nil, &retry.NotFoundError{ LastError: err, LastRequest: input, @@ -303,12 +306,12 @@ func FindAppMonitorByName(ctx context.Context, conn *cloudwatchrum.CloudWatchRUM return output.AppMonitor, nil } -func expandAppMonitorConfiguration(tfMap map[string]interface{}) *cloudwatchrum.AppMonitorConfiguration { +func expandAppMonitorConfiguration(tfMap map[string]interface{}) *awstypes.AppMonitorConfiguration { if tfMap == nil { return nil } - config := &cloudwatchrum.AppMonitorConfiguration{} + config := &awstypes.AppMonitorConfiguration{} if v, ok := tfMap["guest_role_arn"].(string); ok && v != "" { config.GuestRoleArn = aws.String(v) @@ -319,7 +322,7 @@ func expandAppMonitorConfiguration(tfMap map[string]interface{}) *cloudwatchrum. } if v, ok := tfMap["session_sample_rate"].(float64); ok { - config.SessionSampleRate = aws.Float64(v) + config.SessionSampleRate = v } if v, ok := tfMap["allow_cookies"].(bool); ok { @@ -331,25 +334,25 @@ func expandAppMonitorConfiguration(tfMap map[string]interface{}) *cloudwatchrum. } if v, ok := tfMap["excluded_pages"].(*schema.Set); ok && v.Len() > 0 { - config.ExcludedPages = flex.ExpandStringSet(v) + config.ExcludedPages = flex.ExpandStringValueSet(v) } if v, ok := tfMap["favorite_pages"].(*schema.Set); ok && v.Len() > 0 { - config.FavoritePages = flex.ExpandStringSet(v) + config.FavoritePages = flex.ExpandStringValueSet(v) } if v, ok := tfMap["included_pages"].(*schema.Set); ok && v.Len() > 0 { - config.IncludedPages = flex.ExpandStringSet(v) + config.IncludedPages = flex.ExpandStringValueSet(v) } if v, ok := tfMap["telemetries"].(*schema.Set); ok && v.Len() > 0 { - config.Telemetries = flex.ExpandStringSet(v) + config.Telemetries = flex.ExpandStringyValueSet[awstypes.Telemetry](v) } return config } -func flattenAppMonitorConfiguration(apiObject *cloudwatchrum.AppMonitorConfiguration) map[string]interface{} { +func flattenAppMonitorConfiguration(apiObject *awstypes.AppMonitorConfiguration) map[string]interface{} { if apiObject == nil { return nil } @@ -357,67 +360,63 @@ func flattenAppMonitorConfiguration(apiObject *cloudwatchrum.AppMonitorConfigura tfMap := map[string]interface{}{} if v := apiObject.GuestRoleArn; v != nil { - tfMap["guest_role_arn"] = aws.StringValue(v) + tfMap["guest_role_arn"] = aws.ToString(v) } if v := apiObject.IdentityPoolId; v != nil { - tfMap["identity_pool_id"] = aws.StringValue(v) + tfMap["identity_pool_id"] = aws.ToString(v) } - if v := apiObject.SessionSampleRate; v != nil { - tfMap["session_sample_rate"] = aws.Float64Value(v) - } + tfMap["session_sample_rate"] = apiObject.SessionSampleRate if v := apiObject.AllowCookies; v != nil { - tfMap["allow_cookies"] = aws.BoolValue(v) + tfMap["allow_cookies"] = aws.ToBool(v) } if v := apiObject.EnableXRay; v != nil { - tfMap["enable_xray"] = aws.BoolValue(v) + tfMap["enable_xray"] = aws.ToBool(v) } if v := apiObject.Telemetries; v != nil { - tfMap["telemetries"] = flex.FlattenStringSet(v) + tfMap["telemetries"] = apiObject.Telemetries } if v := apiObject.IncludedPages; v != nil { - tfMap["included_pages"] = flex.FlattenStringSet(v) + tfMap["included_pages"] = apiObject.IncludedPages } if v := apiObject.FavoritePages; v != nil { - tfMap["favorite_pages"] = flex.FlattenStringSet(v) + tfMap["favorite_pages"] = apiObject.FavoritePages } if v := apiObject.ExcludedPages; v != nil { - tfMap["excluded_pages"] = flex.FlattenStringSet(v) + tfMap["excluded_pages"] = apiObject.ExcludedPages } return tfMap } -func expandCustomEvents(tfMap map[string]interface{}) *cloudwatchrum.CustomEvents { +func expandCustomEvents(tfMap map[string]interface{}) *awstypes.CustomEvents { if tfMap == nil { return nil } - config := &cloudwatchrum.CustomEvents{} + config := &awstypes.CustomEvents{} if v, ok := tfMap[names.AttrStatus].(string); ok && v != "" { - config.Status = aws.String(v) + config.Status = awstypes.CustomEventsStatus(v) } return config } -func flattenCustomEvents(apiObject *cloudwatchrum.CustomEvents) map[string]interface{} { +func flattenCustomEvents(apiObject *awstypes.CustomEvents) map[string]interface{} { if apiObject == nil { return nil } - tfMap := map[string]interface{}{} - - if v := apiObject.Status; v != nil { - tfMap[names.AttrStatus] = aws.StringValue(v) + tfMap := map[string]interface{}{ + names.AttrStatus: apiObject.Status, } return tfMap diff --git a/internal/service/rum/app_monitor_test.go b/internal/service/rum/app_monitor_test.go index 6fa04922fa7..77ba8805023 100644 --- a/internal/service/rum/app_monitor_test.go +++ b/internal/service/rum/app_monitor_test.go @@ -8,7 +8,7 @@ import ( "fmt" "testing" - "github.com/aws/aws-sdk-go/service/cloudwatchrum" + awstypes "github.com/aws/aws-sdk-go-v2/service/rum/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -21,7 +21,7 @@ import ( func TestAccRUMAppMonitor_basic(t *testing.T) { ctx := acctest.Context(t) - var appMon cloudwatchrum.AppMonitor + var appMon awstypes.AppMonitor rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_rum_app_monitor.test" @@ -73,7 +73,7 @@ func TestAccRUMAppMonitor_basic(t *testing.T) { func TestAccRUMAppMonitor_customEvents(t *testing.T) { ctx := acctest.Context(t) - var appMon cloudwatchrum.AppMonitor + var appMon awstypes.AppMonitor rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_rum_app_monitor.test" @@ -118,7 +118,7 @@ func TestAccRUMAppMonitor_customEvents(t *testing.T) { func TestAccRUMAppMonitor_tags(t *testing.T) { ctx := acctest.Context(t) - var appMon cloudwatchrum.AppMonitor + var appMon awstypes.AppMonitor rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_rum_app_monitor.test" @@ -164,7 +164,7 @@ func TestAccRUMAppMonitor_tags(t *testing.T) { func TestAccRUMAppMonitor_disappears(t *testing.T) { ctx := acctest.Context(t) - var appMon cloudwatchrum.AppMonitor + var appMon awstypes.AppMonitor rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_rum_app_monitor.test" @@ -189,7 +189,7 @@ func TestAccRUMAppMonitor_disappears(t *testing.T) { func testAccCheckAppMonitorDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).RUMConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).RUMClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_rum_app_monitor" { @@ -213,17 +213,14 @@ func testAccCheckAppMonitorDestroy(ctx context.Context) resource.TestCheckFunc { } } -func testAccCheckAppMonitorExists(ctx context.Context, n string, v *cloudwatchrum.AppMonitor) resource.TestCheckFunc { +func testAccCheckAppMonitorExists(ctx context.Context, n string, v *awstypes.AppMonitor) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] if !ok { return fmt.Errorf("Not found: %s", n) } - if rs.Primary.ID == "" { - return fmt.Errorf("No CloudWatch RUM App Monitor ID is set") - } - conn := acctest.Provider.Meta().(*conns.AWSClient).RUMConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).RUMClient(ctx) output, err := tfcloudwatchrum.FindAppMonitorByName(ctx, conn, rs.Primary.ID) diff --git a/internal/service/rum/exports_test.go b/internal/service/rum/exports_test.go new file mode 100644 index 00000000000..bbb5989aa08 --- /dev/null +++ b/internal/service/rum/exports_test.go @@ -0,0 +1,13 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package rum + +// Exports for use in tests only. +var ( + ResourceAppMonitor = resourceAppMonitor + ResourceMetricsDestination = resourceMetricsDestination + + FindAppMonitorByName = findAppMonitorByName + FindMetricsDestinationByName = findMetricsDestinationByName +) diff --git a/internal/service/rum/generate.go b/internal/service/rum/generate.go index a6955d2a2d9..ef736f8cc82 100644 --- a/internal/service/rum/generate.go +++ b/internal/service/rum/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ServiceTagsMap -UpdateTags +//go:generate go run ../../generate/tags/main.go -AWSSDKVersion=2 -KVTValues -ServiceTagsMap -SkipTypesImp -UpdateTags //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/rum/metrics_destination.go b/internal/service/rum/metrics_destination.go index 8104fe459de..3ffdf890754 100644 --- a/internal/service/rum/metrics_destination.go +++ b/internal/service/rum/metrics_destination.go @@ -7,22 +7,23 @@ import ( "context" "log" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/cloudwatchrum" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/rum" + awstypes "github.com/aws/aws-sdk-go-v2/service/rum/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/enum" + "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" "github.com/hashicorp/terraform-provider-aws/names" ) -// @SDKResource("aws_rum_metrics_destination") -func ResourceMetricsDestination() *schema.Resource { +// @SDKResource("aws_rum_metrics_destination", name="Metrics Destination") +func resourceMetricsDestination() *schema.Resource { return &schema.Resource{ CreateWithoutTimeout: resourceMetricsDestinationPut, ReadWithoutTimeout: resourceMetricsDestinationRead, @@ -39,9 +40,9 @@ func ResourceMetricsDestination() *schema.Resource { Required: true, }, names.AttrDestination: { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(cloudwatchrum.MetricDestination_Values(), false), + Type: schema.TypeString, + Required: true, + ValidateDiagFunc: enum.Validate[awstypes.MetricDestination](), }, names.AttrDestinationARN: { Type: schema.TypeString, @@ -59,12 +60,12 @@ func ResourceMetricsDestination() *schema.Resource { func resourceMetricsDestinationPut(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).RUMConn(ctx) + conn := meta.(*conns.AWSClient).RUMClient(ctx) name := d.Get("app_monitor_name").(string) - input := &cloudwatchrum.PutRumMetricsDestinationInput{ + input := &rum.PutRumMetricsDestinationInput{ AppMonitorName: aws.String(name), - Destination: aws.String(d.Get(names.AttrDestination).(string)), + Destination: awstypes.MetricDestination(d.Get(names.AttrDestination).(string)), } if v, ok := d.GetOk(names.AttrDestinationARN); ok { @@ -75,7 +76,7 @@ func resourceMetricsDestinationPut(ctx context.Context, d *schema.ResourceData, input.IamRoleArn = aws.String(v.(string)) } - _, err := conn.PutRumMetricsDestinationWithContext(ctx, input) + _, err := conn.PutRumMetricsDestination(ctx, input) if err != nil { return sdkdiag.AppendErrorf(diags, "putting CloudWatch RUM Metrics Destination (%s): %s", name, err) @@ -90,9 +91,9 @@ func resourceMetricsDestinationPut(ctx context.Context, d *schema.ResourceData, func resourceMetricsDestinationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).RUMConn(ctx) + conn := meta.(*conns.AWSClient).RUMClient(ctx) - dest, err := FindMetricsDestinationByName(ctx, conn, d.Id()) + dest, err := findMetricsDestinationByName(ctx, conn, d.Id()) if !d.IsNewResource() && tfresource.NotFound(err) { log.Printf("[WARN] CloudWatch RUM Metrics Destination %s not found, removing from state", d.Id()) @@ -114,11 +115,11 @@ func resourceMetricsDestinationRead(ctx context.Context, d *schema.ResourceData, func resourceMetricsDestinationDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).RUMConn(ctx) + conn := meta.(*conns.AWSClient).RUMClient(ctx) - input := &cloudwatchrum.DeleteRumMetricsDestinationInput{ + input := &rum.DeleteRumMetricsDestinationInput{ AppMonitorName: aws.String(d.Id()), - Destination: aws.String(d.Get(names.AttrDestination).(string)), + Destination: awstypes.MetricDestination(d.Get(names.AttrDestination).(string)), } if v, ok := d.GetOk(names.AttrDestinationARN); ok { @@ -126,9 +127,9 @@ func resourceMetricsDestinationDelete(ctx context.Context, d *schema.ResourceDat } log.Printf("[DEBUG] Deleting CloudWatch RUM Metrics Destination: %s", d.Id()) - _, err := conn.DeleteRumMetricsDestinationWithContext(ctx, input) + _, err := conn.DeleteRumMetricsDestination(ctx, input) - if tfawserr.ErrCodeEquals(err, cloudwatchrum.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { return diags } @@ -139,44 +140,44 @@ func resourceMetricsDestinationDelete(ctx context.Context, d *schema.ResourceDat return diags } -func FindMetricsDestinationByName(ctx context.Context, conn *cloudwatchrum.CloudWatchRUM, name string) (*cloudwatchrum.MetricDestinationSummary, error) { - input := &cloudwatchrum.ListRumMetricsDestinationsInput{ - AppMonitorName: aws.String(name), +func findMetricsDestination(ctx context.Context, conn *rum.Client, input *rum.ListRumMetricsDestinationsInput) (*awstypes.MetricDestinationSummary, error) { + output, err := findMetricsDestinations(ctx, conn, input) + + if err != nil { + return nil, err } - var output []*cloudwatchrum.MetricDestinationSummary - err := conn.ListRumMetricsDestinationsPagesWithContext(ctx, input, func(page *cloudwatchrum.ListRumMetricsDestinationsOutput, lastPage bool) bool { - if page == nil { - return !lastPage - } + return tfresource.AssertSingleValueResult(output) +} + +func findMetricsDestinations(ctx context.Context, conn *rum.Client, input *rum.ListRumMetricsDestinationsInput) ([]awstypes.MetricDestinationSummary, error) { + var output []awstypes.MetricDestinationSummary - for _, v := range page.Destinations { - if v != nil { - output = append(output, v) + pages := rum.NewListRumMetricsDestinationsPaginator(conn, input) + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if errs.IsA[*awstypes.ResourceNotFoundException](err) { + return nil, &retry.NotFoundError{ + LastError: err, + LastRequest: input, } } - return !lastPage - }) - - if tfawserr.ErrCodeEquals(err, cloudwatchrum.ErrCodeResourceNotFoundException) { - return nil, &retry.NotFoundError{ - LastError: err, - LastRequest: input, + if err != nil { + return nil, err } - } - if err != nil { - return nil, err + output = append(output, page.Destinations...) } - if len(output) == 0 { - return nil, tfresource.NewEmptyResultError(input) - } + return output, nil +} - if count := len(output); count > 1 { - return nil, tfresource.NewTooManyResultsError(count, input) +func findMetricsDestinationByName(ctx context.Context, conn *rum.Client, name string) (*awstypes.MetricDestinationSummary, error) { + input := &rum.ListRumMetricsDestinationsInput{ + AppMonitorName: aws.String(name), } - return output[0], nil + return findMetricsDestination(ctx, conn, input) } diff --git a/internal/service/rum/metrics_destination_test.go b/internal/service/rum/metrics_destination_test.go index 0545df40e64..19b057a4412 100644 --- a/internal/service/rum/metrics_destination_test.go +++ b/internal/service/rum/metrics_destination_test.go @@ -8,7 +8,7 @@ import ( "fmt" "testing" - "github.com/aws/aws-sdk-go/service/cloudwatchrum" + awstypes "github.com/aws/aws-sdk-go-v2/service/rum/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -21,7 +21,7 @@ import ( func TestAccRUMMetricsDestination_basic(t *testing.T) { ctx := acctest.Context(t) - var dest cloudwatchrum.MetricDestinationSummary + var dest awstypes.MetricDestinationSummary rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_rum_metrics_destination.test" @@ -50,7 +50,7 @@ func TestAccRUMMetricsDestination_basic(t *testing.T) { func TestAccRUMMetricsDestination_disappears(t *testing.T) { ctx := acctest.Context(t) - var dest cloudwatchrum.MetricDestinationSummary + var dest awstypes.MetricDestinationSummary rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_rum_metrics_destination.test" @@ -75,7 +75,7 @@ func TestAccRUMMetricsDestination_disappears(t *testing.T) { func TestAccRUMMetricsDestination_disappears_appMonitor(t *testing.T) { ctx := acctest.Context(t) - var dest cloudwatchrum.MetricDestinationSummary + var dest awstypes.MetricDestinationSummary rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix) resourceName := "aws_rum_metrics_destination.test" @@ -100,7 +100,7 @@ func TestAccRUMMetricsDestination_disappears_appMonitor(t *testing.T) { func testAccCheckMetricsDestinationDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).RUMConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).RUMClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_rum_metrics_destination" { @@ -124,17 +124,14 @@ func testAccCheckMetricsDestinationDestroy(ctx context.Context) resource.TestChe } } -func testAccCheckMetricsDestinationExists(ctx context.Context, n string, v *cloudwatchrum.MetricDestinationSummary) resource.TestCheckFunc { +func testAccCheckMetricsDestinationExists(ctx context.Context, n string, v *awstypes.MetricDestinationSummary) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] if !ok { return fmt.Errorf("Not found: %s", n) } - if rs.Primary.ID == "" { - return fmt.Errorf("No CloudWatch RUM Metrics Destination ID is set") - } - conn := acctest.Provider.Meta().(*conns.AWSClient).RUMConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).RUMClient(ctx) output, err := tfcloudwatchrum.FindMetricsDestinationByName(ctx, conn, rs.Primary.ID) diff --git a/internal/service/rum/service_endpoints_gen_test.go b/internal/service/rum/service_endpoints_gen_test.go index a7eb6cee8ef..bc01c610bff 100644 --- a/internal/service/rum/service_endpoints_gen_test.go +++ b/internal/service/rum/service_endpoints_gen_test.go @@ -4,17 +4,20 @@ package rum_test import ( "context" + "errors" "fmt" "maps" - "net/url" "os" "path/filepath" + "reflect" "strings" "testing" - aws_sdkv1 "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/endpoints" - cloudwatchrum_sdkv1 "github.com/aws/aws-sdk-go/service/cloudwatchrum" + aws_sdkv2 "github.com/aws/aws-sdk-go-v2/aws" + awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" + rum_sdkv2 "github.com/aws/aws-sdk-go-v2/service/rum" + "github.com/aws/smithy-go/middleware" + smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" "github.com/hashicorp/aws-sdk-go-base/v2/servicemocks" "github.com/hashicorp/go-cty/cty" @@ -293,54 +296,63 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S } func defaultEndpoint(region string) string { - r := endpoints.DefaultResolver() + r := rum_sdkv2.NewDefaultEndpointResolverV2() - ep, err := r.EndpointFor(cloudwatchrum_sdkv1.EndpointsID, region) + ep, err := r.ResolveEndpoint(context.Background(), rum_sdkv2.EndpointParameters{ + Region: aws_sdkv2.String(region), + }) if err != nil { return err.Error() } - url, _ := url.Parse(ep.URL) - - if url.Path == "" { - url.Path = "/" + if ep.URI.Path == "" { + ep.URI.Path = "/" } - return url.String() + return ep.URI.String() } func defaultFIPSEndpoint(region string) string { - r := endpoints.DefaultResolver() + r := rum_sdkv2.NewDefaultEndpointResolverV2() - ep, err := r.EndpointFor(cloudwatchrum_sdkv1.EndpointsID, region, func(opt *endpoints.Options) { - opt.UseFIPSEndpoint = endpoints.FIPSEndpointStateEnabled + ep, err := r.ResolveEndpoint(context.Background(), rum_sdkv2.EndpointParameters{ + Region: aws_sdkv2.String(region), + UseFIPS: aws_sdkv2.Bool(true), }) if err != nil { return err.Error() } - url, _ := url.Parse(ep.URL) - - if url.Path == "" { - url.Path = "/" + if ep.URI.Path == "" { + ep.URI.Path = "/" } - return url.String() + return ep.URI.String() } func callService(ctx context.Context, t *testing.T, meta *conns.AWSClient) apiCallParams { t.Helper() - client := meta.RUMConn(ctx) + client := meta.RUMClient(ctx) - req, _ := client.ListAppMonitorsRequest(&cloudwatchrum_sdkv1.ListAppMonitorsInput{}) + var result apiCallParams - req.HTTPRequest.URL.Path = "/" - - return apiCallParams{ - endpoint: req.HTTPRequest.URL.String(), - region: aws_sdkv1.StringValue(client.Config.Region), + _, err := client.ListAppMonitors(ctx, &rum_sdkv2.ListAppMonitorsInput{}, + func(opts *rum_sdkv2.Options) { + opts.APIOptions = append(opts.APIOptions, + addRetrieveEndpointURLMiddleware(t, &result.endpoint), + addRetrieveRegionMiddleware(&result.region), + addCancelRequestMiddleware(), + ) + }, + ) + if err == nil { + t.Fatal("Expected an error, got none") + } else if !errors.Is(err, errCancelOperation) { + t.Fatalf("Unexpected error: %s", err) } + + return result } func withNoConfig(_ *caseSetup) { @@ -523,6 +535,89 @@ func testEndpointCase(t *testing.T, region string, testcase endpointTestCase, ca } } +func addRetrieveEndpointURLMiddleware(t *testing.T, endpoint *string) func(*middleware.Stack) error { + return func(stack *middleware.Stack) error { + return stack.Finalize.Add( + retrieveEndpointURLMiddleware(t, endpoint), + middleware.After, + ) + } +} + +func retrieveEndpointURLMiddleware(t *testing.T, endpoint *string) middleware.FinalizeMiddleware { + return middleware.FinalizeMiddlewareFunc( + "Test: Retrieve Endpoint", + func(ctx context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (middleware.FinalizeOutput, middleware.Metadata, error) { + t.Helper() + + request, ok := in.Request.(*smithyhttp.Request) + if !ok { + t.Fatalf("Expected *github.com/aws/smithy-go/transport/http.Request, got %s", fullTypeName(in.Request)) + } + + url := request.URL + url.RawQuery = "" + url.Path = "/" + + *endpoint = url.String() + + return next.HandleFinalize(ctx, in) + }) +} + +func addRetrieveRegionMiddleware(region *string) func(*middleware.Stack) error { + return func(stack *middleware.Stack) error { + return stack.Serialize.Add( + retrieveRegionMiddleware(region), + middleware.After, + ) + } +} + +func retrieveRegionMiddleware(region *string) middleware.SerializeMiddleware { + return middleware.SerializeMiddlewareFunc( + "Test: Retrieve Region", + func(ctx context.Context, in middleware.SerializeInput, next middleware.SerializeHandler) (middleware.SerializeOutput, middleware.Metadata, error) { + *region = awsmiddleware.GetRegion(ctx) + + return next.HandleSerialize(ctx, in) + }, + ) +} + +var errCancelOperation = fmt.Errorf("Test: Canceling request") + +func addCancelRequestMiddleware() func(*middleware.Stack) error { + return func(stack *middleware.Stack) error { + return stack.Finalize.Add( + cancelRequestMiddleware(), + middleware.After, + ) + } +} + +// cancelRequestMiddleware creates a Smithy middleware that intercepts the request before sending and cancels it +func cancelRequestMiddleware() middleware.FinalizeMiddleware { + return middleware.FinalizeMiddlewareFunc( + "Test: Cancel Requests", + func(_ context.Context, in middleware.FinalizeInput, next middleware.FinalizeHandler) (middleware.FinalizeOutput, middleware.Metadata, error) { + return middleware.FinalizeOutput{}, middleware.Metadata{}, errCancelOperation + }) +} + +func fullTypeName(i interface{}) string { + return fullValueTypeName(reflect.ValueOf(i)) +} + +func fullValueTypeName(v reflect.Value) string { + if v.Kind() == reflect.Ptr { + return "*" + fullValueTypeName(reflect.Indirect(v)) + } + + requestType := v.Type() + return fmt.Sprintf("%s.%s", requestType.PkgPath(), requestType.Name()) +} + func generateSharedConfigFile(config configFile) string { var buf strings.Builder diff --git a/internal/service/rum/service_package_gen.go b/internal/service/rum/service_package_gen.go index 7d4b9dfbe77..27ae33426ae 100644 --- a/internal/service/rum/service_package_gen.go +++ b/internal/service/rum/service_package_gen.go @@ -5,10 +5,8 @@ package rum import ( "context" - aws_sdkv1 "github.com/aws/aws-sdk-go/aws" - endpoints_sdkv1 "github.com/aws/aws-sdk-go/aws/endpoints" - session_sdkv1 "github.com/aws/aws-sdk-go/aws/session" - cloudwatchrum_sdkv1 "github.com/aws/aws-sdk-go/service/cloudwatchrum" + aws_sdkv2 "github.com/aws/aws-sdk-go-v2/aws" + rum_sdkv2 "github.com/aws/aws-sdk-go-v2/service/rum" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/types" @@ -32,7 +30,7 @@ func (p *servicePackage) SDKDataSources(ctx context.Context) []*types.ServicePac func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePackageSDKResource { return []*types.ServicePackageSDKResource{ { - Factory: ResourceAppMonitor, + Factory: resourceAppMonitor, TypeName: "aws_rum_app_monitor", Name: "App Monitor", Tags: &types.ServicePackageResourceTags{ @@ -40,8 +38,9 @@ func (p *servicePackage) SDKResources(ctx context.Context) []*types.ServicePacka }, }, { - Factory: ResourceMetricsDestination, + Factory: resourceMetricsDestination, TypeName: "aws_rum_metrics_destination", + Name: "Metrics Destination", }, } } @@ -50,25 +49,23 @@ func (p *servicePackage) ServicePackageName() string { return names.RUM } -// NewConn returns a new AWS SDK for Go v1 client for this service package's AWS API. -func (p *servicePackage) NewConn(ctx context.Context, config map[string]any) (*cloudwatchrum_sdkv1.CloudWatchRUM, error) { - sess := config[names.AttrSession].(*session_sdkv1.Session) +// NewClient returns a new AWS SDK for Go v2 client for this service package's AWS API. +func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) (*rum_sdkv2.Client, error) { + cfg := *(config["aws_sdkv2_config"].(*aws_sdkv2.Config)) - cfg := aws_sdkv1.Config{} + return rum_sdkv2.NewFromConfig(cfg, func(o *rum_sdkv2.Options) { + if endpoint := config[names.AttrEndpoint].(string); endpoint != "" { + tflog.Debug(ctx, "setting endpoint", map[string]any{ + "tf_aws.endpoint": endpoint, + }) + o.BaseEndpoint = aws_sdkv2.String(endpoint) - if endpoint := config[names.AttrEndpoint].(string); endpoint != "" { - tflog.Debug(ctx, "setting endpoint", map[string]any{ - "tf_aws.endpoint": endpoint, - }) - cfg.Endpoint = aws_sdkv1.String(endpoint) - - if sess.Config.UseFIPSEndpoint == endpoints_sdkv1.FIPSEndpointStateEnabled { - tflog.Debug(ctx, "endpoint set, ignoring UseFIPSEndpoint setting") - cfg.UseFIPSEndpoint = endpoints_sdkv1.FIPSEndpointStateDisabled + if o.EndpointOptions.UseFIPSEndpoint == aws_sdkv2.FIPSEndpointStateEnabled { + tflog.Debug(ctx, "endpoint set, ignoring UseFIPSEndpoint setting") + o.EndpointOptions.UseFIPSEndpoint = aws_sdkv2.FIPSEndpointStateDisabled + } } - } - - return cloudwatchrum_sdkv1.New(sess.Copy(&cfg)), nil + }), nil } func ServicePackage(ctx context.Context) conns.ServicePackage { diff --git a/internal/service/rum/sweep.go b/internal/service/rum/sweep.go index 8c8d75be90b..8854334755f 100644 --- a/internal/service/rum/sweep.go +++ b/internal/service/rum/sweep.go @@ -7,12 +7,11 @@ import ( "fmt" "log" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/cloudwatchrum" - "github.com/hashicorp/go-multierror" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/rum" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/sweep" - "github.com/hashicorp/terraform-provider-aws/internal/sweep/awsv1" + "github.com/hashicorp/terraform-provider-aws/internal/sweep/awsv2" ) func RegisterSweepers() { @@ -25,45 +24,40 @@ func RegisterSweepers() { func sweepAppMonitors(region string) error { ctx := sweep.Context(region) client, err := sweep.SharedRegionalSweepClient(ctx, region) - if err != nil { return fmt.Errorf("error getting client: %s", err) } - - conn := client.RUMConn(ctx) + conn := client.RUMClient(ctx) + input := &rum.ListAppMonitorsInput{} sweepResources := make([]sweep.Sweepable, 0) - var errs *multierror.Error - err = conn.ListAppMonitorsPagesWithContext(ctx, &cloudwatchrum.ListAppMonitorsInput{}, func(resp *cloudwatchrum.ListAppMonitorsOutput, lastPage bool) bool { - if len(resp.AppMonitorSummaries) == 0 { - log.Print("[DEBUG] No RUM App Monitors to sweep") - return !lastPage + pages := rum.NewListAppMonitorsPaginator(conn, input) + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + log.Printf("[WARN] Skipping CloudWatch RUM App Monitor sweep for %s: %s", region, err) + return nil } - for _, c := range resp.AppMonitorSummaries { - r := ResourceAppMonitor() + if err != nil { + return fmt.Errorf("error listing CloudWatch RUM App Monitors (%s): %w", region, err) + } + + for _, v := range page.AppMonitorSummaries { + r := resourceAppMonitor() d := r.Data(nil) - d.SetId(aws.StringValue(c.Name)) + d.SetId(aws.ToString(v.Name)) sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client)) } - - return !lastPage - }) - - if err != nil { - errs = multierror.Append(errs, fmt.Errorf("error describing RUM App Monitors: %w", err)) - // in case work can be done, don't jump out yet } - if err = sweep.SweepOrchestrator(ctx, sweepResources); err != nil { - errs = multierror.Append(errs, fmt.Errorf("error sweeping RUM App Monitors for %s: %w", region, err)) - } + err = sweep.SweepOrchestrator(ctx, sweepResources) - if awsv1.SkipSweepError(errs.ErrorOrNil()) { - log.Printf("[WARN] Skipping RUM App Monitor sweep for %s: %s", region, err) - return nil + if err != nil { + return fmt.Errorf("error sweeping CloudWatch RUM App Monitors (%s): %w", region, err) } - return errs.ErrorOrNil() + return nil } diff --git a/internal/service/rum/tags_gen.go b/internal/service/rum/tags_gen.go index b6a4fef6f68..85e91c9825c 100644 --- a/internal/service/rum/tags_gen.go +++ b/internal/service/rum/tags_gen.go @@ -5,9 +5,8 @@ import ( "context" "fmt" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/cloudwatchrum" - "github.com/aws/aws-sdk-go/service/cloudwatchrum/cloudwatchrumiface" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/rum" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/logging" @@ -16,21 +15,21 @@ import ( "github.com/hashicorp/terraform-provider-aws/names" ) -// map[string]*string handling +// map[string]string handling // Tags returns rum service tags. -func Tags(tags tftags.KeyValueTags) map[string]*string { - return aws.StringMap(tags.Map()) +func Tags(tags tftags.KeyValueTags) map[string]string { + return tags.Map() } // KeyValueTags creates tftags.KeyValueTags from rum service tags. -func KeyValueTags(ctx context.Context, tags map[string]*string) tftags.KeyValueTags { +func KeyValueTags(ctx context.Context, tags map[string]string) tftags.KeyValueTags { return tftags.New(ctx, tags) } // getTagsIn returns rum service tags from Context. // nil is returned if there are no input tags. -func getTagsIn(ctx context.Context) map[string]*string { +func getTagsIn(ctx context.Context) map[string]string { if inContext, ok := tftags.FromContext(ctx); ok { if tags := Tags(inContext.TagsIn.UnwrapOrDefault()); len(tags) > 0 { return tags @@ -41,7 +40,7 @@ func getTagsIn(ctx context.Context) map[string]*string { } // setTagsOut sets rum service tags in Context. -func setTagsOut(ctx context.Context, tags map[string]*string) { +func setTagsOut(ctx context.Context, tags map[string]string) { if inContext, ok := tftags.FromContext(ctx); ok { inContext.TagsOut = option.Some(KeyValueTags(ctx, tags)) } @@ -50,7 +49,7 @@ func setTagsOut(ctx context.Context, tags map[string]*string) { // updateTags updates rum service tags. // The identifier is typically the Amazon Resource Name (ARN), although // it may also be a different identifier depending on the service. -func updateTags(ctx context.Context, conn cloudwatchrumiface.CloudWatchRUMAPI, identifier string, oldTagsMap, newTagsMap any) error { +func updateTags(ctx context.Context, conn *rum.Client, identifier string, oldTagsMap, newTagsMap any, optFns ...func(*rum.Options)) error { oldTags := tftags.New(ctx, oldTagsMap) newTags := tftags.New(ctx, newTagsMap) @@ -59,12 +58,12 @@ func updateTags(ctx context.Context, conn cloudwatchrumiface.CloudWatchRUMAPI, i removedTags := oldTags.Removed(newTags) removedTags = removedTags.IgnoreSystem(names.RUM) if len(removedTags) > 0 { - input := &cloudwatchrum.UntagResourceInput{ + input := &rum.UntagResourceInput{ ResourceArn: aws.String(identifier), - TagKeys: aws.StringSlice(removedTags.Keys()), + TagKeys: removedTags.Keys(), } - _, err := conn.UntagResourceWithContext(ctx, input) + _, err := conn.UntagResource(ctx, input, optFns...) if err != nil { return fmt.Errorf("untagging resource (%s): %w", identifier, err) @@ -74,12 +73,12 @@ func updateTags(ctx context.Context, conn cloudwatchrumiface.CloudWatchRUMAPI, i updatedTags := oldTags.Updated(newTags) updatedTags = updatedTags.IgnoreSystem(names.RUM) if len(updatedTags) > 0 { - input := &cloudwatchrum.TagResourceInput{ + input := &rum.TagResourceInput{ ResourceArn: aws.String(identifier), Tags: Tags(updatedTags), } - _, err := conn.TagResourceWithContext(ctx, input) + _, err := conn.TagResource(ctx, input, optFns...) if err != nil { return fmt.Errorf("tagging resource (%s): %w", identifier, err) @@ -92,5 +91,5 @@ func updateTags(ctx context.Context, conn cloudwatchrumiface.CloudWatchRUMAPI, i // UpdateTags updates rum service tags. // It is called from outside this package. func (p *servicePackage) UpdateTags(ctx context.Context, meta any, identifier string, oldTags, newTags any) error { - return updateTags(ctx, meta.(*conns.AWSClient).RUMConn(ctx), identifier, oldTags, newTags) + return updateTags(ctx, meta.(*conns.AWSClient).RUMClient(ctx), identifier, oldTags, newTags) } diff --git a/names/data/names_data.hcl b/names/data/names_data.hcl index 0168a7dc585..c20087c99f0 100644 --- a/names/data/names_data.hcl +++ b/names/data/names_data.hcl @@ -1758,7 +1758,7 @@ service "rum" { sdk { id = "RUM" - client_version = [1] + client_version = [2] } names { diff --git a/names/names.go b/names/names.go index 39923e10b49..e0e207c5513 100644 --- a/names/names.go +++ b/names/names.go @@ -91,6 +91,7 @@ const ( ResourceExplorer2EndpointID = "resource-explorer-2" RolesAnywhereEndpointID = "rolesanywhere" Route53DomainsEndpointID = "route53domains" + RUMEndpointID = "rum" SchemasEndpointID = "schemas" SchedulerEndpointID = "scheduler" ServiceCatalogAppRegistryEndpointID = "servicecatalog-appregistry" diff --git a/tools/tfsdk2fw/go.mod b/tools/tfsdk2fw/go.mod index 66e72dbdc65..9ca6b812a4f 100644 --- a/tools/tfsdk2fw/go.mod +++ b/tools/tfsdk2fw/go.mod @@ -176,6 +176,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/route53 v1.40.10 // indirect github.com/aws/aws-sdk-go-v2/service/route53domains v1.23.10 // indirect github.com/aws/aws-sdk-go-v2/service/route53profiles v1.0.7 // indirect + github.com/aws/aws-sdk-go-v2/service/rum v1.17.12 // indirect github.com/aws/aws-sdk-go-v2/service/s3 v1.55.1 // indirect github.com/aws/aws-sdk-go-v2/service/s3control v1.44.13 // indirect github.com/aws/aws-sdk-go-v2/service/scheduler v1.8.10 // indirect diff --git a/tools/tfsdk2fw/go.sum b/tools/tfsdk2fw/go.sum index bd0b8efdf48..734e3c2fd4b 100644 --- a/tools/tfsdk2fw/go.sum +++ b/tools/tfsdk2fw/go.sum @@ -338,6 +338,8 @@ github.com/aws/aws-sdk-go-v2/service/route53domains v1.23.10 h1:R56F/k3CQZHwrd3k github.com/aws/aws-sdk-go-v2/service/route53domains v1.23.10/go.mod h1:W3+eDMk01Na1U3aQfwGkkEP1Yfe6WUn8hXzyInvGlcU= github.com/aws/aws-sdk-go-v2/service/route53profiles v1.0.7 h1:32/NRAG4ka8/hwr1k9ZA2xwarcJeWO6djaIFJ42tuFg= github.com/aws/aws-sdk-go-v2/service/route53profiles v1.0.7/go.mod h1:H9RRL0qQ+s+XlaZO5s5G3Z8cVZpKEoj313hOyglUwj0= +github.com/aws/aws-sdk-go-v2/service/rum v1.17.12 h1:QeR9ldfI/Hf5sNgvMKi/lnyTKqhg8DQ/BUlRBUuF2tA= +github.com/aws/aws-sdk-go-v2/service/rum v1.17.12/go.mod h1:sd4DiDquert2Ds9FJXnRj8v/78A682gIz1dxjiMRy/I= github.com/aws/aws-sdk-go-v2/service/s3 v1.55.1 h1:UAxBuh0/8sFJk1qOkvOKewP5sWeWaTPDknbQz0ZkDm0= github.com/aws/aws-sdk-go-v2/service/s3 v1.55.1/go.mod h1:hWjsYGjVuqCgfoveVcVFPXIWgz0aByzwaxKlN1StKcM= github.com/aws/aws-sdk-go-v2/service/s3control v1.44.13 h1:HhsZlX5gsL/KfEyHyBO5H0ewgmXoiBpjDPAZ3Ggrj8g= diff --git a/website/docs/r/ec2_network_insights_path.html.markdown b/website/docs/r/ec2_network_insights_path.html.markdown index a76f57a9557..76382d10f75 100644 --- a/website/docs/r/ec2_network_insights_path.html.markdown +++ b/website/docs/r/ec2_network_insights_path.html.markdown @@ -25,7 +25,7 @@ resource "aws_ec2_network_insights_path" "test" { The following arguments are required: * `source` - (Required) ID or ARN of the resource which is the source of the path. Can be an Instance, Internet Gateway, Network Interface, Transit Gateway, VPC Endpoint, VPC Peering Connection or VPN Gateway. If the resource is in another account, you must specify an ARN. -* `destination` - (Required) ID or ARN of the resource which is the destination of the path. Can be an Instance, Internet Gateway, Network Interface, Transit Gateway, VPC Endpoint, VPC Peering Connection or VPN Gateway. If the resource is in another account, you must specify an ARN. +* `destination` - (Optional) ID or ARN of the resource which is the destination of the path. Can be an Instance, Internet Gateway, Network Interface, Transit Gateway, VPC Endpoint, VPC Peering Connection or VPN Gateway. If the resource is in another account, you must specify an ARN. * `protocol` - (Required) Protocol to use for analysis. Valid options are `tcp` or `udp`. The following arguments are optional: