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

r/api_gateway_domain_name: Add support for Regional API Endpoints #2290

Closed
wants to merge 1 commit into from
Closed
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
42 changes: 40 additions & 2 deletions aws/resource_aws_api_gateway_domain_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ func resourceAwsApiGatewayDomainName() *schema.Resource {
"certificate_name": {
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"certificate_arn"},
ConflictsWith: []string{"certificate_arn", "regional_certificate_arn", "regional_certificate_name"},
},
"regional_certificate_name": {
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"certificate_arn", "regional_certificate_name", "certificate_name"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: don't you want to conflict with regional_certificate_arn instead?

},

"certificate_private_key": {
Expand All @@ -52,6 +57,15 @@ func resourceAwsApiGatewayDomainName() *schema.Resource {
ConflictsWith: []string{"certificate_arn"},
},

"endpoint_configuration": {
Type: schema.TypeSet,
//Type: schema.TypeSet,
//Optional: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These 2 lines should be removed

Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
ForceNew: true,
},

"domain_name": {
Type: schema.TypeString,
Required: true,
Expand All @@ -61,7 +75,12 @@ func resourceAwsApiGatewayDomainName() *schema.Resource {
"certificate_arn": {
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"certificate_body", "certificate_chain", "certificate_name", "certificate_private_key"},
ConflictsWith: []string{"certificate_body", "certificate_chain", "certificate_name", "certificate_private_key", "regional_certificate_arn"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want to conflict with regional_certificate_name also?

},
"regional_certificate_arn": {
Type: schema.TypeString,
Optional: true,
ConflictsWith: []string{"certificate_body", "certificate_chain", "certificate_name", "certificate_private_key", "regional_certificate_name"},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want to conflict with certificate_arn also?

},

"cloudfront_domain_name": {
Expand Down Expand Up @@ -90,14 +109,26 @@ func resourceAwsApiGatewayDomainNameCreate(d *schema.ResourceData, meta interfac
DomainName: aws.String(d.Get("domain_name").(string)),
}

if v, ok := d.GetOk("endpoint_configuration"); ok {
params.EndpointConfiguration = expandEndpoints(v.(*schema.Set))
}

if v, ok := d.GetOk("certificate_arn"); ok {
params.CertificateArn = aws.String(v.(string))
}

if v, ok := d.GetOk("regional_certificate_arn"); ok {
params.RegionalCertificateArn = aws.String(v.(string))
}

if v, ok := d.GetOk("certificate_name"); ok {
params.CertificateName = aws.String(v.(string))
}

if v, ok := d.GetOk("regional_certificate_name"); ok {
params.RegionalCertificateName = aws.String(v.(string))
}

if v, ok := d.GetOk("certificate_body"); ok {
params.CertificateBody = aws.String(v.(string))
}
Expand Down Expand Up @@ -208,3 +239,10 @@ func resourceAwsApiGatewayDomainNameDelete(d *schema.ResourceData, meta interfac
return resource.NonRetryableError(err)
})
}

func expandEndpoints(as *schema.Set) *apigateway.EndpointConfiguration {
s := as.List()
var endpoints apigateway.EndpointConfiguration
endpoints.Types = expandStringList(s)
return &endpoints
}