Skip to content

Commit

Permalink
fix: update gnu make file
Browse files Browse the repository at this point in the history
Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com>
  • Loading branch information
AhmedGrati authored and TessaIO committed Mar 15, 2023
1 parent cc69467 commit 60cbc4b
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 47 deletions.
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:enhancement
data-source/aws_appmesh_virtual_gateway: Add new data-source for the aws_appmesh_virtual_gateway
```
4 changes: 2 additions & 2 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ docs-lint:
echo "Unexpected misspelling found in docs files."; \
echo "To automatically fix the misspelling, run 'make docs-lint-fix' and commit the changes."; \
exit 1)
@docker run --platform linux/amd64 --rm -v $(PWD):/markdown 06kellyjac/markdownlint-cli docs/ || (echo; \
@docker run --rm -v $(PWD):/markdown 06kellyjac/markdownlint-cli docs/ || (echo; \
echo "Unexpected issues found in docs Markdown files."; \
echo "To apply any automatic fixes, run 'make docs-lint-fix' and commit the changes."; \
exit 1)
Expand Down Expand Up @@ -319,7 +319,7 @@ website-lint:
echo "Unexpected mispelling found in website files."; \
echo "To automatically fix the misspelling, run 'make website-lint-fix' and commit the changes."; \
exit 1)
@docker run --rm --platform linux/amd64 -v $(PWD):/markdown 06kellyjac/markdownlint-cli website/docs/ || (echo; \
@docker run --rm -v $(PWD):/markdown 06kellyjac/markdownlint-cli website/docs/ || (echo; \
echo "Unexpected issues found in website Markdown files."; \
echo "To apply any automatic fixes, run 'make website-lint-fix' and commit the changes."; \
exit 1)
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.

26 changes: 14 additions & 12 deletions internal/service/appmesh/virtual_gateway_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@ package appmesh
// know about it.

import (
"fmt"
"context"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/appmesh"
"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"
"github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag"
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
)

// @SDKDataSource("aws_appmesh_virtual_gateway")
func DataSourceVirtualGateway() *schema.Resource {
return &schema.Resource{
Read: dataSourceVirtualGatewayRead,
ReadWithoutTimeout: dataSourceVirtualGatewayRead,

Schema: map[string]*schema.Schema{
"name": {
Expand Down Expand Up @@ -508,9 +511,9 @@ func DataSourceVirtualGateway() *schema.Resource {

}

func dataSourceVirtualGatewayRead(d *schema.ResourceData, meta interface{}) error {

conn := meta.(*conns.AWSClient).AppMeshConn
func dataSourceVirtualGatewayRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
var diags diag.Diagnostics
conn := meta.(*conns.AWSClient).AppMeshConn()
ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig

req := &appmesh.DescribeVirtualGatewayInput{
Expand All @@ -521,10 +524,9 @@ func dataSourceVirtualGatewayRead(d *schema.ResourceData, meta interface{}) erro
if v, ok := d.GetOk("mesh_owner"); ok {
req.MeshOwner = aws.String(v.(string))
}

resp, err := conn.DescribeVirtualGateway(req)
resp, err := conn.DescribeVirtualGatewayWithContext(ctx, req)
if err != nil {
return fmt.Errorf("error reading App Mesh Virtual Gateway: %s", err)
return sdkdiag.AppendErrorf(diags, "error reading App Mesh Virtual Gateway: %s", err)
}

arn := aws.StringValue(resp.VirtualGateway.Metadata.Arn)
Expand All @@ -541,17 +543,17 @@ func dataSourceVirtualGatewayRead(d *schema.ResourceData, meta interface{}) erro

err = d.Set("spec", flattenVirtualGatewaySpec(resp.VirtualGateway.Spec))
if err != nil {
return fmt.Errorf("error setting spec: %s", err)
return sdkdiag.AppendErrorf(diags, "error setting spec: %s", err)
}

tags, err := ListTags(conn, arn)
tags, err := ListTags(ctx, conn, arn)

if err != nil {
return fmt.Errorf("error listing tags for App Mesh Virtual Service (%s): %s", arn, err)
return sdkdiag.AppendErrorf(diags, "error listing tags for App Mesh Virtual Service (%s): %s", arn, err)
}

if err := d.Set("tags", tags.IgnoreAWS().IgnoreConfig(ignoreTagsConfig).Map()); err != nil {
return fmt.Errorf("error setting tags: %s", err)
return sdkdiag.AppendErrorf(diags, "error setting tags: %s", err)
}

return nil
Expand Down
69 changes: 38 additions & 31 deletions internal/service/appmesh/virtual_gateway_data_source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ import (
)

func TestAccAppMeshVirtualGatewayDataSource_basic(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_appmesh_virtual_gateway.test"
dataSourceName := "data.aws_appmesh_virtual_gateway.test"
vgName := fmt.Sprintf("tf-acc-test-%d-mesh-local", sdkacctest.RandInt())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t); acctest.PreCheckPartitionHasService(appmesh.EndpointsID, t) },
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, appmesh.EndpointsID) },
ErrorCheck: acctest.ErrorCheck(t, appmesh.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckMeshDestroy,
CheckDestroy: testAccCheckMeshDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccVirtualGatewayDataSourceConfig_basic(rName, vgName),
Expand All @@ -41,16 +42,17 @@ func TestAccAppMeshVirtualGatewayDataSource_basic(t *testing.T) {
}

func TestAccAppMeshVirtualGatewayDataSource_backendDefaults(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_appmesh_virtual_gateway.test"
dataSourceName := "data.aws_appmesh_virtual_gateway.test"
vgName := fmt.Sprintf("tf-acc-test-%d-mesh-local", sdkacctest.RandInt())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t); acctest.PreCheckPartitionHasService(appmesh.EndpointsID, t) },
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, appmesh.EndpointsID) },
ErrorCheck: acctest.ErrorCheck(t, appmesh.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckMeshDestroy,
CheckDestroy: testAccCheckMeshDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccVirtualGatewayDataSourceConfig_backendDefaults(rName, vgName),
Expand All @@ -72,16 +74,17 @@ func TestAccAppMeshVirtualGatewayDataSource_backendDefaults(t *testing.T) {
}

func TestAccAppMeshVirtualGatewayDataSource_backendDefaultsUpdated(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_appmesh_virtual_gateway.test"
dataSourceName := "data.aws_appmesh_virtual_gateway.test"
vgName := fmt.Sprintf("tf-acc-test-%d-mesh-local", sdkacctest.RandInt())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t); acctest.PreCheckPartitionHasService(appmesh.EndpointsID, t) },
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, appmesh.EndpointsID) },
ErrorCheck: acctest.ErrorCheck(t, appmesh.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckMeshDestroy,
CheckDestroy: testAccCheckMeshDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccVirtualGatewayDataSourceConfig_backendDefaultsUpdated(rName, vgName),
Expand All @@ -104,16 +107,17 @@ func TestAccAppMeshVirtualGatewayDataSource_backendDefaultsUpdated(t *testing.T)
}

func TestAccAppMeshVirtualGatewayDataSource_backendDefaultsCertificate(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_appmesh_virtual_gateway.test"
dataSourceName := "data.aws_appmesh_virtual_gateway.test"
vgName := fmt.Sprintf("tf-acc-test-%d-mesh-local", sdkacctest.RandInt())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t); acctest.PreCheckPartitionHasService(appmesh.EndpointsID, t) },
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, appmesh.EndpointsID) },
ErrorCheck: acctest.ErrorCheck(t, appmesh.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckMeshDestroy,
CheckDestroy: testAccCheckMeshDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccVirtualGatewayDataSourceConfig_backendDefaultsCertificate(rName, vgName),
Expand All @@ -137,16 +141,17 @@ func TestAccAppMeshVirtualGatewayDataSource_backendDefaultsCertificate(t *testin
}

func TestAccAppMeshVirtualGatewayDataSource_listenerConnectionPool(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_appmesh_virtual_gateway.test"
dataSourceName := "data.aws_appmesh_virtual_gateway.test"
vgName := fmt.Sprintf("tf-acc-test-%d-mesh-local", sdkacctest.RandInt())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t); acctest.PreCheckPartitionHasService(appmesh.EndpointsID, t) },
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, appmesh.EndpointsID) },
ErrorCheck: acctest.ErrorCheck(t, appmesh.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckMeshDestroy,
CheckDestroy: testAccCheckMeshDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccVirtualGatewayDataSourceConfig_listenerConnectionPool(rName, vgName),
Expand All @@ -167,16 +172,17 @@ func TestAccAppMeshVirtualGatewayDataSource_listenerConnectionPool(t *testing.T)
}

func TestAccAppMeshVirtualGatewayDataSource_listenerConnectionPoolUpdated(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_appmesh_virtual_gateway.test"
dataSourceName := "data.aws_appmesh_virtual_gateway.test"
vgName := fmt.Sprintf("tf-acc-test-%d-mesh-local", sdkacctest.RandInt())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t); acctest.PreCheckPartitionHasService(appmesh.EndpointsID, t) },
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, appmesh.EndpointsID) },
ErrorCheck: acctest.ErrorCheck(t, appmesh.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckMeshDestroy,
CheckDestroy: testAccCheckMeshDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccVirtualGatewayDataSourceConfig_listenerConnectionPoolUpdated(rName, vgName),
Expand All @@ -198,16 +204,17 @@ func TestAccAppMeshVirtualGatewayDataSource_listenerConnectionPoolUpdated(t *tes
}

func TestAccAppMeshVirtualGatewayDataSource_listenerHealthChecks(t *testing.T) {
ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_appmesh_virtual_gateway.test"
dataSourceName := "data.aws_appmesh_virtual_gateway.test"
vgName := fmt.Sprintf("tf-acc-test-%d-mesh-local", sdkacctest.RandInt())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t); acctest.PreCheckPartitionHasService(appmesh.EndpointsID, t) },
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, appmesh.EndpointsID) },
ErrorCheck: acctest.ErrorCheck(t, appmesh.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckMeshDestroy,
CheckDestroy: testAccCheckMeshDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccVirtualGatewayDataSourceConfig_listenerHealthChecks(rName, vgName),
Expand All @@ -233,7 +240,7 @@ func TestAccAppMeshVirtualGatewayDataSource_listenerHealthChecks(t *testing.T) {
}

func TestAccAppMeshVirtualGatewayDataSource_listenerTLSACM(t *testing.T) {

ctx := acctest.Context(t)
var ca acmpca.CertificateAuthority
acmCAResourceName := "aws_acmpca_certificate_authority.test"
domain := acctest.RandomDomainName()
Expand All @@ -244,17 +251,17 @@ func TestAccAppMeshVirtualGatewayDataSource_listenerTLSACM(t *testing.T) {
vgName := fmt.Sprintf("tf-acc-test-%d-mesh-local", sdkacctest.RandInt())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t); acctest.PreCheckPartitionHasService(appmesh.EndpointsID, t) },
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, appmesh.EndpointsID) },
ErrorCheck: acctest.ErrorCheck(t, appmesh.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckMeshDestroy,
CheckDestroy: testAccCheckMeshDestroy(ctx),
Steps: []resource.TestStep{
// We need to create and activate the CA before issuing a certificate.
{
Config: testAccVirtualGatewayDataSourceConfig_rootCA(domain),
Check: resource.ComposeTestCheckFunc(
acctest.CheckACMPCACertificateAuthorityExists(acmCAResourceName, &ca),
acctest.CheckACMPCACertificateAuthorityActivateRootCA(&ca),
acctest.CheckACMPCACertificateAuthorityExists(ctx, acmCAResourceName, &ca),
acctest.CheckACMPCACertificateAuthorityActivateRootCA(ctx, &ca),
),
},
{
Expand All @@ -277,17 +284,17 @@ func TestAccAppMeshVirtualGatewayDataSource_listenerTLSACM(t *testing.T) {
}

func TestAccAppMeshVirtualGatewayDataSource_listenerTLSFile(t *testing.T) {

ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_appmesh_virtual_gateway.test"
dataSourceName := "data.aws_appmesh_virtual_gateway.test"
vgName := fmt.Sprintf("tf-acc-test-%d-mesh-local", sdkacctest.RandInt())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t); acctest.PreCheckPartitionHasService(appmesh.EndpointsID, t) },
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, appmesh.EndpointsID) },
ErrorCheck: acctest.ErrorCheck(t, appmesh.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckMeshDestroy,
CheckDestroy: testAccCheckMeshDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccVirtualGatewayDataSourceConfig_listenerTLSFile(rName, vgName),
Expand All @@ -310,17 +317,17 @@ func TestAccAppMeshVirtualGatewayDataSource_listenerTLSFile(t *testing.T) {
}

func TestAccAppMeshVirtualGatewayDataSource_listenerValidation(t *testing.T) {

ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_appmesh_virtual_gateway.test"
dataSourceName := "data.aws_appmesh_virtual_gateway.test"
vgName := fmt.Sprintf("tf-acc-test-%d-mesh-local", sdkacctest.RandInt())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t); acctest.PreCheckPartitionHasService(appmesh.EndpointsID, t) },
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, appmesh.EndpointsID) },
ErrorCheck: acctest.ErrorCheck(t, appmesh.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckMeshDestroy,
CheckDestroy: testAccCheckMeshDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccVirtualGatewayDataSourceConfig_listenerValidation(rName, vgName),
Expand All @@ -344,18 +351,18 @@ func TestAccAppMeshVirtualGatewayDataSource_listenerValidation(t *testing.T) {
}

func TestAccAppMeshVirtualGatewayDataSource_logging(t *testing.T) {

ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_appmesh_virtual_gateway.test"
dataSourceName := "data.aws_appmesh_virtual_gateway.test"
vgName := fmt.Sprintf("tf-acc-test-%d-mesh-local", sdkacctest.RandInt())
path := "/tmp/access.log"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t); acctest.PreCheckPartitionHasService(appmesh.EndpointsID, t) },
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, appmesh.EndpointsID) },
ErrorCheck: acctest.ErrorCheck(t, appmesh.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckMeshDestroy,
CheckDestroy: testAccCheckMeshDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccVirtualGatewayDataSourceConfig_logging(rName, vgName, path),
Expand All @@ -376,17 +383,17 @@ func TestAccAppMeshVirtualGatewayDataSource_logging(t *testing.T) {
}

func TestAccAppMeshVirtualGatewayDataSource_tags(t *testing.T) {

ctx := acctest.Context(t)
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
resourceName := "aws_appmesh_virtual_gateway.test"
dataSourceName := "data.aws_appmesh_virtual_gateway.test"
vgName := fmt.Sprintf("tf-acc-test-%d-mesh-local", sdkacctest.RandInt())

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(t); acctest.PreCheckPartitionHasService(appmesh.EndpointsID, t) },
PreCheck: func() { acctest.PreCheck(ctx, t); acctest.PreCheckPartitionHasService(t, appmesh.EndpointsID) },
ErrorCheck: acctest.ErrorCheck(t, appmesh.EndpointsID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckMeshDestroy,
CheckDestroy: testAccCheckMeshDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccVirtualGatewayDataSourceConfig_tags(rName, vgName, "key1", "value1"),
Expand Down
2 changes: 0 additions & 2 deletions website/docs/d/appmesh_virtual_gateway.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ data "aws_appmesh_virtual_gateway" "test" {

The following arguments are required:


* `name` - (Required) Name of the virtual gateway.
* `mesh_name` - (Required) Name of the service mesh in which the virtual gateway exists.
* `mesh_owner` - (Optional) AWS account ID of the service mesh's owner.
Expand All @@ -44,7 +43,6 @@ The following arguments are required:

In addition to all arguments above, the following attributes are exported:


* `arn` - ARN of the virtual gateway.
* `created_date` - Creation date of the virtual gateway.
* `last_updated_date` - Last update date of the virtual gateway.
Expand Down

0 comments on commit 60cbc4b

Please sign in to comment.