Skip to content

Commit

Permalink
r/aws_appmesh_virtual_service: Reduce visibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Apr 24, 2024
1 parent 0e4b5f3 commit 33ac30f
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 46 deletions.
2 changes: 2 additions & 0 deletions internal/service/appmesh/exports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ var (
ResourceVirtualGateway = resourceVirtualGateway
ResourceVirtualNode = resourceVirtualNode
ResourceVirtualRouter = resourceVirtualRouter
ResourceVirtualService = resourceVirtualService

FindGatewayRouteByFourPartKey = findGatewayRouteByFourPartKey
FindMeshByTwoPartKey = findMeshByTwoPartKey
FindRouteByFourPartKey = findRouteByFourPartKey
FindVirtualGatewayByThreePartKey = findVirtualGatewayByThreePartKey
FindVirtualNodeByThreePartKey = findVirtualNodeByThreePartKey
FindVirtualRouterByThreePartKey = findVirtualRouterByThreePartKey
FindVirtualServiceByThreePartKey = findVirtualServiceByThreePartKey
)
2 changes: 1 addition & 1 deletion internal/service/appmesh/service_package_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/service/appmesh/sweep.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func sweepVirtualServices(region string) error {

for _, v := range page.VirtualServices {
virtualServiceName := aws.StringValue(v.VirtualServiceName)
r := ResourceVirtualService()
r := resourceVirtualService()
d := r.Data(nil)
d.SetId(fmt.Sprintf("%s/%s", meshName, virtualServiceName)) // Logged in Delete handler, not used in API call.
d.Set("mesh_name", meshName)
Expand Down
88 changes: 45 additions & 43 deletions internal/service/appmesh/virtual_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (

// @SDKResource("aws_appmesh_virtual_service", name="Virtual Service")
// @Tags(identifierAttribute="arn")
func ResourceVirtualService() *schema.Resource {
func resourceVirtualService() *schema.Resource {
return &schema.Resource{
CreateWithoutTimeout: resourceVirtualServiceCreate,
ReadWithoutTimeout: resourceVirtualServiceRead,
Expand All @@ -38,45 +38,47 @@ func ResourceVirtualService() *schema.Resource {
StateContext: resourceVirtualServiceImport,
},

Schema: map[string]*schema.Schema{
"arn": {
Type: schema.TypeString,
Computed: true,
},
"created_date": {
Type: schema.TypeString,
Computed: true,
},
"last_updated_date": {
Type: schema.TypeString,
Computed: true,
},
"mesh_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringLenBetween(1, 255),
},
"mesh_owner": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: verify.ValidAccountID,
},
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringLenBetween(1, 255),
},
"resource_owner": {
Type: schema.TypeString,
Computed: true,
},
"spec": resourceVirtualServiceSpecSchema(),
names.AttrTags: tftags.TagsSchema(),
names.AttrTagsAll: tftags.TagsSchemaComputed(),
SchemaFunc: func() map[string]*schema.Schema {
return map[string]*schema.Schema{
"arn": {
Type: schema.TypeString,
Computed: true,
},
"created_date": {
Type: schema.TypeString,
Computed: true,
},
"last_updated_date": {
Type: schema.TypeString,
Computed: true,
},
"mesh_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringLenBetween(1, 255),
},
"mesh_owner": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ValidateFunc: verify.ValidAccountID,
},
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validation.StringLenBetween(1, 255),
},
"resource_owner": {
Type: schema.TypeString,
Computed: true,
},
"spec": resourceVirtualServiceSpecSchema(),
names.AttrTags: tftags.TagsSchema(),
names.AttrTagsAll: tftags.TagsSchemaComputed(),
}
},

CustomizeDiff: verify.SetTagsDiff,
Expand Down Expand Up @@ -170,7 +172,7 @@ func resourceVirtualServiceRead(ctx context.Context, d *schema.ResourceData, met
conn := meta.(*conns.AWSClient).AppMeshConn(ctx)

outputRaw, err := tfresource.RetryWhenNewResourceNotFound(ctx, propagationTimeout, func() (interface{}, error) {
return FindVirtualServiceByThreePartKey(ctx, conn, d.Get("mesh_name").(string), d.Get("mesh_owner").(string), d.Get("name").(string))
return findVirtualServiceByThreePartKey(ctx, conn, d.Get("mesh_name").(string), d.Get("mesh_owner").(string), d.Get("name").(string))
}, d.IsNewResource())

if !d.IsNewResource() && tfresource.NotFound(err) {
Expand Down Expand Up @@ -262,7 +264,7 @@ func resourceVirtualServiceImport(ctx context.Context, d *schema.ResourceData, m
meshName := parts[0]
name := parts[1]

vs, err := FindVirtualServiceByThreePartKey(ctx, conn, meshName, "", name)
vs, err := findVirtualServiceByThreePartKey(ctx, conn, meshName, "", name)

if err != nil {
return nil, err
Expand All @@ -275,7 +277,7 @@ func resourceVirtualServiceImport(ctx context.Context, d *schema.ResourceData, m
return []*schema.ResourceData{d}, nil
}

func FindVirtualServiceByThreePartKey(ctx context.Context, conn *appmesh.AppMesh, meshName, meshOwner, name string) (*appmesh.VirtualServiceData, error) {
func findVirtualServiceByThreePartKey(ctx context.Context, conn *appmesh.AppMesh, meshName, meshOwner, name string) (*appmesh.VirtualServiceData, error) {
input := &appmesh.DescribeVirtualServiceInput{
MeshName: aws.String(meshName),
VirtualServiceName: aws.String(name),
Expand Down
2 changes: 1 addition & 1 deletion internal/service/appmesh/virtual_service_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func dataSourceVirtualServiceRead(ctx context.Context, d *schema.ResourceData, m
ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig

virtualServiceName := d.Get("name").(string)
vs, err := FindVirtualServiceByThreePartKey(ctx, conn, d.Get("mesh_name").(string), d.Get("mesh_owner").(string), virtualServiceName)
vs, err := findVirtualServiceByThreePartKey(ctx, conn, d.Get("mesh_name").(string), d.Get("mesh_owner").(string), virtualServiceName)

if err != nil {
return sdkdiag.AppendErrorf(diags, "reading App Mesh Virtual Service (%s): %s", virtualServiceName, err)
Expand Down

0 comments on commit 33ac30f

Please sign in to comment.