Skip to content

[New Resource] - aws_wafv2_application_integration_url #42769

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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/42769.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-data-source
aws_wafv2_application_integration_url
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package wafv2

import (
"context"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/wafv2"
awstypes "github.com/aws/aws-sdk-go-v2/service/wafv2/types"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-provider-aws/internal/create"
"github.com/hashicorp/terraform-provider-aws/internal/framework"
"github.com/hashicorp/terraform-provider-aws/names"
)

// @FrameworkDataSource("aws_wafv2_application_integration_url", name="Application Integration URL")
func newDataSourceApplicationIntegrationURL(context.Context) (datasource.DataSourceWithConfigure, error) {
return &dataSourceApplicationIntegrationURL{}, nil
}

const (
ApplicationIntegrationURL = "Captcha API Application Integration URL Data Source"
)

type dataSourceApplicationIntegrationURL struct {
framework.DataSourceWithConfigure
}

func (d *dataSourceApplicationIntegrationURL) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
names.AttrURL: schema.StringAttribute{
Computed: true,
},
},
}
}

func (d *dataSourceApplicationIntegrationURL) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
conn := d.Meta().WAFV2Client(ctx)

var data dataSourceApplicationIntegrationURLModel

resp.Diagnostics.Append(req.Config.Get(ctx, &data)...)
if resp.Diagnostics.HasError() {
return
}

input := wafv2.ListAPIKeysInput{
Scope: awstypes.ScopeRegional,
Limit: aws.Int32(1),
}

out, err := conn.ListAPIKeys(ctx, &input)
if err != nil {
resp.Diagnostics.AddError(
create.ProblemStandardMessage(names.WAFV2, create.ErrActionReading, ApplicationIntegrationURL, data.URL.String(), err),
err.Error(),
)
return
}

data.URL = types.StringValue(aws.ToString(out.ApplicationIntegrationURL))

resp.Diagnostics.Append(resp.State.Set(ctx, &data)...)
if resp.Diagnostics.HasError() {
return
}
}

type dataSourceApplicationIntegrationURLModel struct {
URL types.String `tfsdk:"url"`
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package wafv2_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-provider-aws/internal/acctest"
"github.com/hashicorp/terraform-provider-aws/names"
)

func TestAccWAFV2ApplicationIntegrationURLDataSource_basic(t *testing.T) {
ctx := acctest.Context(t)
dataSourceName := "data.aws_wafv2_application_integration_url.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t); testAccPreCheckScopeRegional(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, names.WAFV2ServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckAPIKeyDestroy(ctx),
Steps: []resource.TestStep{
{
Config: `data "aws_wafv2_application_integration_url" "test" {}`,
Check: resource.ComposeAggregateTestCheckFunc(
acctest.CheckResourceAttrHasPrefix(dataSourceName, names.AttrURL, "https://"),
),
},
},
})
}
8 changes: 7 additions & 1 deletion internal/service/wafv2/service_package_gen.go

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

26 changes: 26 additions & 0 deletions website/docs/d/wafv2_application_integration_url.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
subcategory: "WAF"
layout: "aws"
page_title: "AWS: aws_wafv2_application_integration_url"
description: |-
Retrieves WAF Captcha Application Integration URL.
---
# Data Source: aws_wafv2_application_integration_url

Retrieves WAF Captcha Application Integration URL.

## Example Usage

```terraform
data "aws_wafv2_application_integration_url" "example" {}
```

## Argument Reference

This data source does not support any arguments.

## Attribute Reference

This data source exports the following attributes in addition to the arguments above:

* `url` - The Application Integration URL.
Loading