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

Caching on API Gateway does not work for path parameters #856

Closed
betabandido opened this issue Jun 14, 2017 · 6 comments
Closed

Caching on API Gateway does not work for path parameters #856

betabandido opened this issue Jun 14, 2017 · 6 comments
Labels
enhancement Requests to existing resources that expand the functionality or scope.

Comments

@betabandido
Copy link
Contributor

When enabling caching on an API that uses path parameters (or query strings) it is necessary to create a cache key for the parameter (or query string). But, Terraform currently does not seem to allow to set cache keys. If caching is enabled for a given method (something currently possible to do with Terraform), the same cached value will be returned no matter whether the path parameter value is the same or not.

In resourceAwsApiGatewayIntegrationCreate method the method integration is created but both CacheKeyParameters and CacheNamespace are set to nil:

	_, err := conn.PutIntegration(&apigateway.PutIntegrationInput{
		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)),
		Type:       aws.String(d.Get("type").(string)),
		IntegrationHttpMethod: integrationHttpMethod,
		Uri:                 uri,
		RequestParameters:   aws.StringMap(parameters),
		RequestTemplates:    aws.StringMap(templates),
		Credentials:         credentials,
		CacheNamespace:      nil,
		CacheKeyParameters:  nil,
		PassthroughBehavior: passthroughBehavior,
		ContentHandling:     contentHandling,
	})

(see code at https://github.com/terraform-providers/terraform-provider-aws/blob/master/aws/resource_aws_api_gateway_integration.go#L153)

Additionally, when trying to enable caching for a path parameter in the AWS console (after an API has been created by Terraform) the operation fails. This might be related to using nil in the PutIntegration call.

We are working on a pull request to provide a working solution. Any help would be appreciated.

Terraform Version

Terraform v0.9.8

The issue seems to be present in the master branch too.

Affected Resource(s)

aws_api_gateway_integration

@radeksimko radeksimko added the enhancement Requests to existing resources that expand the functionality or scope. label Jun 15, 2017
@betabandido
Copy link
Contributor Author

Enabling caching does not properly work even for very simple use cases (such as when having path parameters or query strings). So, IMHO I would not say this is just an "enhancement."

We have created a pull request to fix this issue. Hopefully it can make it into the next release :)

@Ninir
Copy link
Contributor

Ninir commented Sep 6, 2017

Hi @betabandido

As your PR was merged, and mine about the documentation will be too soon I hope, could you tell me if you are still having this issue or is it all resolved?

Thanks!

@betabandido
Copy link
Contributor Author

@Ninir

Oh, the issue was already fixed with the proposed PR. I suppose we just forgot to close the issue. I will do it now.

Thanks for the documentation! It was on my backlog, but I couldn't find the time to do it yet.

@Ninir
Copy link
Contributor

Ninir commented Sep 7, 2017

@betabandido No worries, thanks for your quick response :)

(and cheers for the work made! 😄 )

@bubunyo
Copy link

bubunyo commented Sep 13, 2017

I don't know if this the right place to say this, but anytime include the cache keys in the integrations resource, the enable cache check box is not enabled by default. how do I enable that checkbox with terraform?

@ghost
Copy link

ghost commented Apr 11, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 11, 2020
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope.
Projects
None yet
Development

No branches or pull requests

4 participants