-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"}, | ||
}, | ||
|
||
"certificate_private_key": { | ||
|
@@ -52,6 +57,15 @@ func resourceAwsApiGatewayDomainName() *schema.Resource { | |
ConflictsWith: []string{"certificate_arn"}, | ||
}, | ||
|
||
"endpoint_configuration": { | ||
Type: schema.TypeSet, | ||
//Type: schema.TypeSet, | ||
//Optional: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
|
@@ -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"}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we want to conflict with |
||
}, | ||
"regional_certificate_arn": { | ||
Type: schema.TypeString, | ||
Optional: true, | ||
ConflictsWith: []string{"certificate_body", "certificate_chain", "certificate_name", "certificate_private_key", "regional_certificate_name"}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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": { | ||
|
@@ -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)) | ||
} | ||
|
@@ -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 | ||
} |
There was a problem hiding this comment.
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?