pulumi-aws
pulumi-aws copied to clipboard
InvalidArgument: The parameter ForwardedValues cannot be used when a cache policy is associated to the cache behavior
When updating an aws.cloudfront.Distribution instance from:
defaultCacheBehavior: {
targetOriginId: originId,
forwardedValues: {
cookies: {
forward: 'none',
},
queryString: false,
},
allowedMethods: [
'GET',
'HEAD',
'OPTIONS',
'PUT',
'POST',
'PATCH',
'DELETE',
],
cachedMethods: ['GET', 'HEAD', 'OPTIONS'],
viewerProtocolPolicy: 'allow-all',
},
to
defaultCacheBehavior: {
targetOriginId: originId,
cachePolicyId: cfCachePolicy.id,
originRequestPolicyId: cfOriginRequestPolicy.id,
allowedMethods: [
'GET',
'HEAD',
'OPTIONS',
'PUT',
'POST',
'PATCH',
'DELETE',
],
cachedMethods: ['GET', 'HEAD', 'OPTIONS'],
viewerProtocolPolicy: 'allow-all',
},
pulumi up errors with:
InvalidArgument: The parameter ForwardedValues cannot be used when a cache policy is associated to the cache behavior
then, I have to export stack > remove forwardedValues references, import stack, and reapply
Expected behavior
pulumi phases the change in 2 (ie remove forwardedvalues, add cachepolicy), if a single update not allowed by aws
Current behavior
error above
Steps to reproduce
delta above
Context (Environment)
pulumi version 2.21.2 under pulumi's docker image
Affected feature
pulumi up
This is an upstream bug tracked in https://github.com/hashicorp/terraform-provider-aws/issues/17626
You have to disable the forwarded section if applying a custom cache_policy and origin_request_policy.
Eg/- ordered_cache_behavior { path_pattern = "/*" allowed_methods = ["GET", "HEAD", "OPTIONS"] cached_methods = ["GET", "HEAD"] target_origin_id = "${var.s3_origin_id}" #origin_request_policy_id = aws_cloudfront_origin_request_policy.origin_request_policy.name #cache_policy_id = aws_cloudfront_cache_policy.cache_policy.name origin_request_policy_id = aws_cloudfront_origin_request_policy.origin_request_policy.id cache_policy_id = aws_cloudfront_cache_policy.cache_policy.id
# forwarded_values {
# query_string = false
#
# cookies {
# forward = "none"
# }
# }
min_ttl = 0
default_ttl = 3600
max_ttl = 86400
compress = true
viewer_protocol_policy = "redirect-to-https"
}
I can confirm this issue. The only workaround is to remove cachePolicyId which is not ideal.
Hi, I had the same issue in Terraform and resolve with parameters use_forwarded_values = false . i hope this can help you