Fixed acceptance test that was failing due to undefined log bucket
This commit is contained in:
parent
b79aea491b
commit
822c8f9a32
|
@ -44,8 +44,8 @@ func TestAccAWSCloudFrontDistribution_S3Origin(t *testing.T) {
|
|||
|
||||
func TestAccAWSCloudFrontDistribution_S3OriginWithTags(t *testing.T) {
|
||||
ri := acctest.RandInt()
|
||||
preConfig := fmt.Sprintf(testAccAWSCloudFrontDistributionS3ConfigWithTags, ri, testAccAWSCloudFrontDistributionRetainConfig())
|
||||
postConfig := fmt.Sprintf(testAccAWSCloudFrontDistributionS3ConfigWithTagsUpdated, ri, testAccAWSCloudFrontDistributionRetainConfig())
|
||||
preConfig := fmt.Sprintf(testAccAWSCloudFrontDistributionS3ConfigWithTags, ri, originBucket, logBucket, testAccAWSCloudFrontDistributionRetainConfig())
|
||||
postConfig := fmt.Sprintf(testAccAWSCloudFrontDistributionS3ConfigWithTagsUpdated, ri, originBucket, logBucket, testAccAWSCloudFrontDistributionRetainConfig())
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -251,26 +251,41 @@ func testAccAWSCloudFrontDistributionRetainConfig() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
var originBucket = fmt.Sprintf(`
|
||||
resource "aws_s3_bucket" "s3_bucket_origin" {
|
||||
bucket = "mybucket.${var.rand_id}"
|
||||
acl = "public-read"
|
||||
}
|
||||
`)
|
||||
|
||||
var logBucket = fmt.Sprintf(`
|
||||
resource "aws_s3_bucket" "s3_bucket_logs" {
|
||||
bucket = "mylogs.${var.rand_id}"
|
||||
acl = "public-read"
|
||||
}
|
||||
`)
|
||||
|
||||
var testAccAWSCloudFrontDistributionS3Config = fmt.Sprintf(`
|
||||
variable rand_id {
|
||||
default = %d
|
||||
}
|
||||
|
||||
resource "aws_s3_bucket" "s3_bucket" {
|
||||
bucket = "mybucket.${var.rand_id}.s3.amazonaws.com"
|
||||
acl = "public-read"
|
||||
}
|
||||
# origin bucket
|
||||
%s
|
||||
|
||||
# log bucket
|
||||
%s
|
||||
|
||||
resource "aws_cloudfront_distribution" "s3_distribution" {
|
||||
origin {
|
||||
domain_name = "${aws_s3_bucket.s3_bucket.id}"
|
||||
domain_name = "${aws_s3_bucket.s3_bucket_origin.id}.s3.amazonaws.com"
|
||||
origin_id = "myS3Origin"
|
||||
}
|
||||
enabled = true
|
||||
default_root_object = "index.html"
|
||||
logging_config {
|
||||
include_cookies = false
|
||||
bucket = "mylogs.${var.rand_id}.s3.amazonaws.com"
|
||||
bucket = "${aws_s3_bucket.s3_bucket_logs.id}.s3.amazonaws.com"
|
||||
prefix = "myprefix"
|
||||
}
|
||||
aliases = [ "mysite.${var.rand_id}.example.com", "yoursite.${var.rand_id}.example.com" ]
|
||||
|
@ -301,21 +316,22 @@ resource "aws_cloudfront_distribution" "s3_distribution" {
|
|||
}
|
||||
%s
|
||||
}
|
||||
`, rand.New(rand.NewSource(time.Now().UnixNano())).Int(), testAccAWSCloudFrontDistributionRetainConfig())
|
||||
`, rand.New(rand.NewSource(time.Now().UnixNano())).Int(), originBucket, logBucket, testAccAWSCloudFrontDistributionRetainConfig())
|
||||
|
||||
var testAccAWSCloudFrontDistributionS3ConfigWithTags = `
|
||||
variable rand_id {
|
||||
default = %d
|
||||
}
|
||||
|
||||
resource "aws_s3_bucket" "s3_bucket" {
|
||||
bucket = "mybucket.${var.rand_id}.s3.amazonaws.com"
|
||||
acl = "public-read"
|
||||
}
|
||||
# origin bucket
|
||||
%s
|
||||
|
||||
# log bucket
|
||||
%s
|
||||
|
||||
resource "aws_cloudfront_distribution" "s3_distribution" {
|
||||
origin {
|
||||
domain_name = "${aws_s3_bucket.s3_bucket.id}"
|
||||
domain_name = "${aws_s3_bucket.s3_bucket_origin.id}.s3.amazonaws.com"
|
||||
origin_id = "myS3Origin"
|
||||
}
|
||||
enabled = true
|
||||
|
@ -359,14 +375,15 @@ variable rand_id {
|
|||
default = %d
|
||||
}
|
||||
|
||||
resource "aws_s3_bucket" "s3_bucket" {
|
||||
bucket = "mybucket.${var.rand_id}.s3.amazonaws.com"
|
||||
acl = "public-read"
|
||||
}
|
||||
# origin bucket
|
||||
%s
|
||||
|
||||
# log bucket
|
||||
%s
|
||||
|
||||
resource "aws_cloudfront_distribution" "s3_distribution" {
|
||||
origin {
|
||||
domain_name = "${aws_s3_bucket.s3_bucket.id}"
|
||||
domain_name = "${aws_s3_bucket.s3_bucket_origin.id}.s3.amazonaws.com"
|
||||
origin_id = "myS3Origin"
|
||||
}
|
||||
enabled = true
|
||||
|
@ -409,6 +426,9 @@ variable rand_id {
|
|||
default = %d
|
||||
}
|
||||
|
||||
# log bucket
|
||||
%s
|
||||
|
||||
resource "aws_cloudfront_distribution" "custom_distribution" {
|
||||
origin {
|
||||
domain_name = "www.example.com"
|
||||
|
@ -425,7 +445,7 @@ resource "aws_cloudfront_distribution" "custom_distribution" {
|
|||
default_root_object = "index.html"
|
||||
logging_config {
|
||||
include_cookies = false
|
||||
bucket = "mylogs.${var.rand_id}.s3.amazonaws.com"
|
||||
bucket = "${aws_s3_bucket.s3_bucket_logs.id}.s3.amazonaws.com"
|
||||
prefix = "myprefix"
|
||||
}
|
||||
aliases = [ "mysite.${var.rand_id}.example.com", "*.yoursite.${var.rand_id}.example.com" ]
|
||||
|
@ -457,21 +477,22 @@ resource "aws_cloudfront_distribution" "custom_distribution" {
|
|||
}
|
||||
%s
|
||||
}
|
||||
`, rand.New(rand.NewSource(time.Now().UnixNano())).Int(), testAccAWSCloudFrontDistributionRetainConfig())
|
||||
`, rand.New(rand.NewSource(time.Now().UnixNano())).Int(), logBucket, testAccAWSCloudFrontDistributionRetainConfig())
|
||||
|
||||
var testAccAWSCloudFrontDistributionMultiOriginConfig = fmt.Sprintf(`
|
||||
variable rand_id {
|
||||
default = %d
|
||||
}
|
||||
|
||||
resource "aws_s3_bucket" "s3_bucket" {
|
||||
bucket = "mybucket.${var.rand_id}.s3.amazonaws.com"
|
||||
acl = "public-read"
|
||||
}
|
||||
# origin bucket
|
||||
%s
|
||||
|
||||
# log bucket
|
||||
%s
|
||||
|
||||
resource "aws_cloudfront_distribution" "multi_origin_distribution" {
|
||||
origin {
|
||||
domain_name = "${aws_s3_bucket.s3_bucket.id}"
|
||||
domain_name = "${aws_s3_bucket.s3_bucket_origin.id}.s3.amazonaws.com"
|
||||
origin_id = "myS3Origin"
|
||||
}
|
||||
origin {
|
||||
|
@ -489,7 +510,7 @@ resource "aws_cloudfront_distribution" "multi_origin_distribution" {
|
|||
default_root_object = "index.html"
|
||||
logging_config {
|
||||
include_cookies = false
|
||||
bucket = "mylogs.${var.rand_id}.s3.amazonaws.com"
|
||||
bucket = "${aws_s3_bucket.s3_bucket_logs.id}.s3.amazonaws.com"
|
||||
prefix = "myprefix"
|
||||
}
|
||||
aliases = [ "mysite.${var.rand_id}.example.com", "*.yoursite.${var.rand_id}.example.com" ]
|
||||
|
@ -509,7 +530,7 @@ resource "aws_cloudfront_distribution" "multi_origin_distribution" {
|
|||
max_ttl = 100
|
||||
viewer_protocol_policy = "allow-all"
|
||||
}
|
||||
cache_behavior {
|
||||
cache_behaviors = [{
|
||||
allowed_methods = [ "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT" ]
|
||||
cached_methods = [ "GET", "HEAD" ]
|
||||
target_origin_id = "myS3Origin"
|
||||
|
@ -524,8 +545,8 @@ resource "aws_cloudfront_distribution" "multi_origin_distribution" {
|
|||
max_ttl = 50
|
||||
viewer_protocol_policy = "allow-all"
|
||||
path_pattern = "images1/*.jpg"
|
||||
}
|
||||
cache_behavior {
|
||||
},
|
||||
{
|
||||
allowed_methods = [ "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT" ]
|
||||
cached_methods = [ "GET", "HEAD" ]
|
||||
target_origin_id = "myCustomOrigin"
|
||||
|
@ -540,7 +561,7 @@ resource "aws_cloudfront_distribution" "multi_origin_distribution" {
|
|||
max_ttl = 50
|
||||
viewer_protocol_policy = "allow-all"
|
||||
path_pattern = "images2/*.jpg"
|
||||
}
|
||||
}]
|
||||
price_class = "PriceClass_All"
|
||||
custom_error_response {
|
||||
error_code = 404
|
||||
|
@ -558,7 +579,7 @@ resource "aws_cloudfront_distribution" "multi_origin_distribution" {
|
|||
}
|
||||
%s
|
||||
}
|
||||
`, rand.New(rand.NewSource(time.Now().UnixNano())).Int(), testAccAWSCloudFrontDistributionRetainConfig())
|
||||
`, rand.New(rand.NewSource(time.Now().UnixNano())).Int(), originBucket, logBucket, testAccAWSCloudFrontDistributionRetainConfig())
|
||||
|
||||
var testAccAWSCloudFrontDistributionNoCustomErroResponseInfo = fmt.Sprintf(`
|
||||
variable rand_id {
|
||||
|
|
Loading…
Reference in New Issue