Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New DataSource: aws_appmesh_virtual_gateway #27057

Merged
merged 18 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/27057.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-data-source
aws_appmesh_virtual_gateway
```
1 change: 1 addition & 0 deletions internal/service/appmesh/appmesh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func TestAccAppMesh_serial(t *testing.T) {
"multiListenerValidation": testAccVirtualGateway_MultiListenerValidation,
"logging": testAccVirtualGateway_Logging,
"tags": testAccVirtualGateway_Tags,
"dataSourceBasic": testAccVirtualGatewayDataSource_basic,
},
"VirtualNode": {
"basic": testAccVirtualNode_basic,
Expand Down
23 changes: 0 additions & 23 deletions internal/service/appmesh/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,3 @@ func FindGatewayRoute(ctx context.Context, conn *appmesh.AppMesh, meshName, virt

return output.GatewayRoute, nil
}

// FindVirtualGateway returns the virtual gateway corresponding to the specified mesh name, virtual gateway name and optional mesh owner.
// Returns an error if no virtual gateway is found.
func FindVirtualGateway(ctx context.Context, conn *appmesh.AppMesh, meshName, virtualGatewayName, meshOwner string) (*appmesh.VirtualGatewayData, error) {
input := &appmesh.DescribeVirtualGatewayInput{
MeshName: aws.String(meshName),
VirtualGatewayName: aws.String(virtualGatewayName),
}
if meshOwner != "" {
input.MeshOwner = aws.String(meshOwner)
}

output, err := conn.DescribeVirtualGatewayWithContext(ctx, input)
if err != nil {
return nil, err
}

if output == nil {
return nil, nil
}

return output.VirtualGateway, nil
}
13 changes: 6 additions & 7 deletions internal/service/appmesh/mesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,22 +298,21 @@ func dataSourcePropertyFromResourceProperty(rs *schema.Schema) *schema.Schema {
case schema.TypeSet:
ds.Set = rs.Set
fallthrough
case schema.TypeList:
case schema.TypeList, schema.TypeMap:
// List & Set types are generally used for 2 cases:
// - a list/set of simple primitive values (e.g. list of strings)
// - a sub resource
if elem, ok := rs.Elem.(*schema.Resource); ok {
// Maps are usually used for maps of simple primitives
switch elem := rs.Elem.(type) {
case *schema.Resource:
// handle the case where the Element is a sub-resource
ds.Elem = &schema.Resource{
Schema: dataSourceSchemaFromResourceSchema(elem.Schema),
}
} else {
case *schema.Schema:
// handle simple primitive case
ds.Elem = rs.Elem
ds.Elem = &schema.Schema{Type: elem.Type}
}
default:
// Elem of all other types are copied as-is
ds.Elem = rs.Elem
}

return ds
Expand Down
4 changes: 4 additions & 0 deletions internal/service/appmesh/service_package_gen.go

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

Loading