provider/aws: Allow empty S3 config in Cloudfront Origin (#6487)
* provider/aws: Allow empty S3 config in Cloudfront Origin
This commit is contained in:
parent
be74cb2892
commit
c58892485b
|
@ -527,6 +527,15 @@ func expandOrigin(m map[string]interface{}) *cloudfront.Origin {
|
||||||
origin.S3OriginConfig = expandS3OriginConfig(s[0].(map[string]interface{}))
|
origin.S3OriginConfig = expandS3OriginConfig(s[0].(map[string]interface{}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if both custom and s3 origin are missing, add an empty s3 origin
|
||||||
|
// One or the other must be specified, but the S3 origin can be "empty"
|
||||||
|
if origin.S3OriginConfig == nil && origin.CustomOriginConfig == nil {
|
||||||
|
origin.S3OriginConfig = &cloudfront.S3OriginConfig{
|
||||||
|
OriginAccessIdentity: aws.String(""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return origin
|
return origin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -544,7 +553,9 @@ func flattenOrigin(or *cloudfront.Origin) map[string]interface{} {
|
||||||
m["origin_path"] = *or.OriginPath
|
m["origin_path"] = *or.OriginPath
|
||||||
}
|
}
|
||||||
if or.S3OriginConfig != nil {
|
if or.S3OriginConfig != nil {
|
||||||
m["s3_origin_config"] = schema.NewSet(s3OriginConfigHash, []interface{}{flattenS3OriginConfig(or.S3OriginConfig)})
|
if or.S3OriginConfig.OriginAccessIdentity != nil && *or.S3OriginConfig.OriginAccessIdentity != "" {
|
||||||
|
m["s3_origin_config"] = schema.NewSet(s3OriginConfigHash, []interface{}{flattenS3OriginConfig(or.S3OriginConfig)})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,7 +195,6 @@ resource "aws_cloudfront_distribution" "s3_distribution" {
|
||||||
origin {
|
origin {
|
||||||
domain_name = "${aws_s3_bucket.s3_bucket.id}"
|
domain_name = "${aws_s3_bucket.s3_bucket.id}"
|
||||||
origin_id = "myS3Origin"
|
origin_id = "myS3Origin"
|
||||||
s3_origin_config {}
|
|
||||||
}
|
}
|
||||||
enabled = true
|
enabled = true
|
||||||
default_root_object = "index.html"
|
default_root_object = "index.html"
|
||||||
|
@ -303,7 +302,6 @@ resource "aws_cloudfront_distribution" "multi_origin_distribution" {
|
||||||
origin {
|
origin {
|
||||||
domain_name = "${aws_s3_bucket.s3_bucket.id}"
|
domain_name = "${aws_s3_bucket.s3_bucket.id}"
|
||||||
origin_id = "myS3Origin"
|
origin_id = "myS3Origin"
|
||||||
s3_origin_config {}
|
|
||||||
}
|
}
|
||||||
origin {
|
origin {
|
||||||
domain_name = "www.example.com"
|
domain_name = "www.example.com"
|
||||||
|
|
Loading…
Reference in New Issue