Merge pull request #9175 from PayscaleNateW/provider/aws/fix-acceptance-test-log-bucket
Provider/aws/fix acceptance test log bucket
This commit is contained in:
commit
60f0603f1c
|
@ -1,12 +1,17 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
)
|
||||
|
||||
func TestAccAWSCloudFrontDistribution_importBasic(t *testing.T) {
|
||||
ri := acctest.RandInt()
|
||||
testConfig := fmt.Sprintf(testAccAWSCloudFrontDistributionS3Config, ri, originBucket, logBucket, testAccAWSCloudFrontDistributionRetainConfig())
|
||||
|
||||
resourceName := "aws_cloudfront_distribution.s3_distribution"
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
|
@ -15,7 +20,7 @@ func TestAccAWSCloudFrontDistribution_importBasic(t *testing.T) {
|
|||
CheckDestroy: testAccCheckCloudFrontDistributionDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAWSCloudFrontDistributionS3Config,
|
||||
Config: testConfig,
|
||||
},
|
||||
resource.TestStep{
|
||||
ResourceName: resourceName,
|
||||
|
|
|
@ -20,13 +20,15 @@ import (
|
|||
// If you are testing manually and can't wait for deletion, set the
|
||||
// TF_TEST_CLOUDFRONT_RETAIN environment variable.
|
||||
func TestAccAWSCloudFrontDistribution_S3Origin(t *testing.T) {
|
||||
ri := acctest.RandInt()
|
||||
testConfig := fmt.Sprintf(testAccAWSCloudFrontDistributionS3Config, ri, originBucket, logBucket, testAccAWSCloudFrontDistributionRetainConfig())
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testAccCheckCloudFrontDistributionDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: testAccAWSCloudFrontDistributionS3Config,
|
||||
Config: testConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testAccCheckCloudFrontDistributionExistence(
|
||||
"aws_cloudfront_distribution.s3_distribution",
|
||||
|
@ -44,8 +46,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 +253,41 @@ func testAccAWSCloudFrontDistributionRetainConfig() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
var testAccAWSCloudFrontDistributionS3Config = fmt.Sprintf(`
|
||||
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 = `
|
||||
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 +318,22 @@ resource "aws_cloudfront_distribution" "s3_distribution" {
|
|||
}
|
||||
%s
|
||||
}
|
||||
`, rand.New(rand.NewSource(time.Now().UnixNano())).Int(), 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 +377,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 +428,9 @@ variable rand_id {
|
|||
default = %d
|
||||
}
|
||||
|
||||
# log bucket
|
||||
%s
|
||||
|
||||
resource "aws_cloudfront_distribution" "custom_distribution" {
|
||||
origin {
|
||||
domain_name = "www.example.com"
|
||||
|
@ -425,7 +447,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 +479,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 +512,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" ]
|
||||
|
@ -541,6 +564,7 @@ resource "aws_cloudfront_distribution" "multi_origin_distribution" {
|
|||
viewer_protocol_policy = "allow-all"
|
||||
path_pattern = "images2/*.jpg"
|
||||
}
|
||||
|
||||
price_class = "PriceClass_All"
|
||||
custom_error_response {
|
||||
error_code = 404
|
||||
|
@ -558,7 +582,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