-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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/aws: aws_api_gateway_method_response headers? #6092
Comments
Hi @ijin This hasn't been implemented yet. I just found the following in the code: func resourceAwsApiGatewayIntegrationResponseCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).apigateway
templates := make(map[string]string)
for k, v := range d.Get("response_templates").(map[string]interface{}) {
templates[k] = v.(string)
}
_, err := conn.PutIntegrationResponse(&apigateway.PutIntegrationResponseInput{
HttpMethod: aws.String(d.Get("http_method").(string)),
ResourceId: aws.String(d.Get("resource_id").(string)),
RestApiId: aws.String(d.Get("rest_api_id").(string)),
StatusCode: aws.String(d.Get("status_code").(string)),
ResponseTemplates: aws.StringMap(templates),
// TODO implement once [GH-2143](https://github.com/hashicorp/terraform/issues/2143) has been implemented
ResponseParameters: nil,
})
if err != nil {
return fmt.Errorf("Error creating API Gateway Integration Response: %s", err)
}
d.SetId(fmt.Sprintf("agir-%s-%s-%s-%s", d.Get("rest_api_id").(string), d.Get("resource_id").(string), d.Get("http_method").(string), d.Get("status_code").(string)))
log.Printf("[DEBUG] API Gateway Integration Response ID: %s", d.Id())
return nil
} Notice the comment there above Thanks Paul |
oh, thanks. looks like it's going to take a while.. |
is there any reason this can't be implemented before fixing #2143? i assume this would work with JSON syntax and it's critical for us. |
Another options here is to expose a different API: It looks like AWS sdk go expects the following for response paramaters: {
"integration.response.body.type/Content-Type": true
} While aws sdk node expects: {
"Content-Type": "integration.response.body.type"
} If terraform exposed an api that looked more like nodes, would we be in the clear?
|
Welp forget that. Just realized I mixed-up the types for integration response and method response parameters. |
I think the observation stands though. We can change up the terraform api so that there are no dots in keys. method response response parameters could look like:
and integration response could look like:
Then the provider can change the keys to be of the form |
Then, assuming I have the prefix right, the code becomes: func resourceAwsApiGatewayIntegrationResponseCreate(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).apigateway
templates := make(map[string]string)
for k, v := range d.Get("response_templates").(map[string]interface{}) {
templates[k] = v.(string)
}
paramaters := make(map[string]string)
for k, v := range d.Get("response_paramaters").(map[string]interface{}) {
paramaters["integration.response.header." + k] = v.(string)
}
_, err := conn.PutIntegrationResponse(&apigateway.PutIntegrationResponseInput{
HttpMethod: aws.String(d.Get("http_method").(string)),
ResourceId: aws.String(d.Get("resource_id").(string)),
RestApiId: aws.String(d.Get("rest_api_id").(string)),
StatusCode: aws.String(d.Get("status_code").(string)),
ResponseTemplates: aws.StringMap(templates),
ResponseParameters: aws.StringMap(paramaters),
})
if err != nil {
return fmt.Errorf("Error creating API Gateway Integration Response: %s", err)
}
d.SetId(fmt.Sprintf("agir-%s-%s-%s-%s", d.Get("rest_api_id").(string), d.Get("resource_id").(string), d.Get("http_method").(string), d.Get("status_code").(string)))
log.Printf("[DEBUG] API Gateway Integration Response ID: %s", d.Id())
return nil
} |
@radeksimko would love to get your thoughts on changing the api to avoid #2143 |
@joshrtay While I totally understand the need to get this implemented with or without #2143 I'm not entirely sure about this approach. If we're really going to implement this without #2143 I believe there should be an easy way to migrate users to the correct DSL once #2143 is fixed. I was thinking along the lines of raw JSON, e.g. response_paramaters_in_json = <<PARAMS
{
"integration.response.body.type/Content-Type": true
}
PARAMS it may not look as nice and natural, but it respects the API/SDK and provides a fairly clean migration path to a state when #2143 is fixed - e.g. we can mark Also the field name suggests what is expected from the user ( What do you think? |
That works for me. When using JSON syntax I assume you'd still have to use the
|
If you (for any reason) didn't want to use the HEREDOC syntax I presented in the example above, then yes, it would look exactly like that - including the backslashes. We could also use |
Ok got it. I'd love to get this in master by the end of the week. If it would speed things up, I'd be happy to submit a pull request. Though I have zero go experience. |
@radeksimko Took a stab at it. #6344 |
#6344 merged, it will be available in the next release It may be reimplemented in the future once as discussed above, but I'm closing this issue for now. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Are setting response headers implemented yet?
I need to set headers like
Access-Control-Allow-Origin
to my responses in API GW.The text was updated successfully, but these errors were encountered: