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

provider: Remove deprecated kinesis_analytics and r53 custom endpoint arguments #14238

Merged
merged 1 commit into from
Jul 24, 2020
Merged
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
8 changes: 0 additions & 8 deletions aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,14 +589,6 @@ func (c *Config) Client() (interface{}, error) {
s3Config.DisableRestProtocolURICleaning = aws.Bool(true)
client.s3connUriCleaningDisabled = s3.New(sess.Copy(s3Config))

// Handle deprecated endpoint configurations
if c.Endpoints["kinesis_analytics"] != "" {
client.kinesisanalyticsconn = kinesisanalytics.New(sess.Copy(&aws.Config{Endpoint: aws.String(c.Endpoints["kinesis_analytics"])}))
}
if c.Endpoints["r53"] != "" {
route53Config.Endpoint = aws.String(c.Endpoints["r53"])
}

// Force "global" services to correct regions
switch partition {
case endpoints.AwsPartitionID:
Expand Down
6 changes: 0 additions & 6 deletions aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,6 @@ func init() {
"iotanalytics",
"iotevents",
"kafka",
"kinesis_analytics",
"kinesis",
"kinesisanalytics",
"kinesisanalyticsv2",
Expand Down Expand Up @@ -1126,7 +1125,6 @@ func init() {
"pricing",
"qldb",
"quicksight",
"r53",
"ram",
"rds",
"redshift",
Expand Down Expand Up @@ -1345,10 +1343,6 @@ func endpointsSchema() *schema.Schema {
}
}

// Since the endpoints attribute is a TypeSet we cannot use ConflictsWith
endpointsAttributes["kinesis_analytics"].Deprecated = "use `endpoints` configuration block `kinesisanalytics` argument instead"
endpointsAttributes["r53"].Deprecated = "use `endpoints` configuration block `route53` argument instead"

return &schema.Schema{
Type: schema.TypeSet,
Optional: true,
Expand Down
88 changes: 0 additions & 88 deletions aws/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,11 +812,6 @@ func TestAccAWSProvider_Endpoints(t *testing.T) {

// Initialize each endpoint configuration with matching name and value
for _, endpointServiceName := range endpointServiceNames {
// Skip deprecated endpoint configurations as they will override expected values
if endpointServiceName == "kinesis_analytics" || endpointServiceName == "r53" {
continue
}

endpoints.WriteString(fmt.Sprintf("%s = \"http://%s\"\n", endpointServiceName, endpointServiceName))
}

Expand All @@ -835,34 +830,6 @@ func TestAccAWSProvider_Endpoints(t *testing.T) {
})
}

func TestAccAWSProvider_Endpoints_Deprecated(t *testing.T) {
var providers []*schema.Provider
var endpointsDeprecated strings.Builder

// Initialize each deprecated endpoint configuration with matching name and value
for _, endpointServiceName := range endpointServiceNames {
// Only configure deprecated endpoint configurations
if endpointServiceName != "kinesis_analytics" && endpointServiceName != "r53" {
continue
}

endpointsDeprecated.WriteString(fmt.Sprintf("%s = \"http://%s\"\n", endpointServiceName, endpointServiceName))
}

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProviderFactories: testAccProviderFactories(&providers),
CheckDestroy: nil,
Steps: []resource.TestStep{
{
Config: testAccAWSProviderConfigEndpoints(endpointsDeprecated.String()),
Check: resource.ComposeTestCheckFunc(
testAccCheckAWSProviderEndpointsDeprecated(&providers)),
},
},
})
}

func TestAccAWSProvider_IgnoreTags_EmptyConfigurationBlock(t *testing.T) {
var providers []*schema.Provider

Expand Down Expand Up @@ -1144,61 +1111,6 @@ func testAccCheckAWSProviderEndpoints(providers *[]*schema.Provider) resource.Te
providerClient := provider.Meta().(*AWSClient)

for _, endpointServiceName := range endpointServiceNames {
// Skip deprecated endpoint configurations as they will override expected values
if endpointServiceName == "kinesis_analytics" || endpointServiceName == "r53" {
continue
}

providerClientField := reflect.Indirect(reflect.ValueOf(providerClient)).FieldByNameFunc(endpointFieldNameF(endpointServiceName))

if !providerClientField.IsValid() {
return fmt.Errorf("unable to match AWSClient struct field name for endpoint name: %s", endpointServiceName)
}

actualEndpoint := reflect.Indirect(reflect.Indirect(providerClientField).FieldByName("Config").FieldByName("Endpoint")).String()
expectedEndpoint := fmt.Sprintf("http://%s", endpointServiceName)

if actualEndpoint != expectedEndpoint {
return fmt.Errorf("expected endpoint (%s) value (%s), got: %s", endpointServiceName, expectedEndpoint, actualEndpoint)
}
}
}

return nil
}
}

func testAccCheckAWSProviderEndpointsDeprecated(providers *[]*schema.Provider) resource.TestCheckFunc {
return func(s *terraform.State) error {
if providers == nil {
return fmt.Errorf("no providers initialized")
}

// Match AWSClient struct field names to endpoint configuration names
endpointFieldNameF := func(endpoint string) func(string) bool {
return func(name string) bool {
switch endpoint {
case "kinesis_analytics":
endpoint = "kinesisanalytics"
}

return name == fmt.Sprintf("%sconn", endpoint)
}
}

for _, provider := range *providers {
if provider == nil || provider.Meta() == nil || provider.Meta().(*AWSClient) == nil {
continue
}

providerClient := provider.Meta().(*AWSClient)

for _, endpointServiceName := range endpointServiceNames {
// Only check deprecated endpoint configurations
if endpointServiceName != "kinesis_analytics" && endpointServiceName != "r53" {
continue
}

providerClientField := reflect.Indirect(reflect.ValueOf(providerClient)).FieldByNameFunc(endpointFieldNameF(endpointServiceName))

if !providerClientField.IsValid() {
Expand Down
2 changes: 0 additions & 2 deletions website/docs/guides/custom-service-endpoints.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ The Terraform AWS Provider allows the following endpoints to be customized:
<li><code>iotanalytics</code></li>
<li><code>iotevents</code></li>
<li><code>kafka</code></li>
<li><code>kinesis_analytics</code> (<b>DEPRECATED</b> Use <code>kinesisanalytics</code> instead)</li>
<li><code>kinesis</code></li>
<li><code>kinesisanalytics</code></li>
<li><code>kinesisanalyticsv2</code></li>
Expand Down Expand Up @@ -159,7 +158,6 @@ The Terraform AWS Provider allows the following endpoints to be customized:
<li><code>pricing</code></li>
<li><code>qldb</code></li>
<li><code>quicksight</code></li>
<li><code>r53</code></li> (<b>DEPRECATED</b> Use <code>route53</code> instead)</li>
<li><code>ram</code></li>
<li><code>rds</code></li>
<li><code>redshift</code></li>
Expand Down
37 changes: 37 additions & 0 deletions website/docs/guides/version-3-upgrade.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Upgrade topics:

- [Provider Version Configuration](#provider-version-configuration)
- [Provider Authentication Updates](#provider-authentication-updates)
- [Provider Custom Service Endpoint Updates](#provider-custom-service-endpoint-updates)
- [Data Source: aws_availability_zones](#data-source-aws_availability_zones)
- [Data Source: aws_lambda_invocation](#data-source-aws_lambda_invocation)
- [Resource: aws_acm_certificate](#resource-aws_acm_certificate)
Expand Down Expand Up @@ -93,6 +94,42 @@ The `AWS_SDK_LOAD_CONFIG` environment variable is no longer necessary for the pr

The provider now relies on the default AWS Go SDK timeouts for interacting with the EC2 Instance Metadata Service.

## Provider Custom Service Endpoint Updates

### Removal of kinesis_analytics and r53 Arguments

The [custom service endpoints](custom-service-endpoints.html) for Kinesis Analytics and Route 53 now use the `kinesisanalytics` and `route53` argument names in the provider configuration.

For example, given this previous configuration:

```hcl
provider "aws" {
# ... potentially other configuration ...

endpoints {
# ... potentially other configuration ...

kinesis_analytics = "https://example.com"
r53 = "https://example.com"
}
}
```

An updated configuration:

```hcl
provider "aws" {
# ... potentially other configuration ...

endpoints {
# ... potentially other configuration ...

kinesisanalytics = "https://example.com"
route53 = "https://example.com"
}
}
```

## Data Source: aws_availability_zones

### blacklisted_names Attribute Removal
Expand Down