Skip to content

Commit

Permalink
Randomize name of S3 bucket in acctest
Browse files Browse the repository at this point in the history
  • Loading branch information
Radek Simko committed Feb 17, 2016
1 parent db0d48e commit 8a29b91
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions builtin/providers/aws/resource_aws_lambda_permission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/lambda"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
Expand Down Expand Up @@ -266,6 +267,8 @@ func TestAccAWSLambdaPermission_multiplePerms(t *testing.T) {
}

func TestAccAWSLambdaPermission_withS3(t *testing.T) {
rInt := acctest.RandInt()

var statement LambdaPolicyStatement
endsWithFuncName := regexp.MustCompile(":function:lambda_function_name_perm_s3$")

Expand All @@ -275,7 +278,7 @@ func TestAccAWSLambdaPermission_withS3(t *testing.T) {
CheckDestroy: testAccCheckAWSLambdaPermissionDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSLambdaPermissionConfig_withS3,
Config: fmt.Sprintf(testAccAWSLambdaPermissionConfig_withS3_tpl, rInt),
Check: resource.ComposeTestCheckFunc(
testAccCheckLambdaPermissionExists("aws_lambda_permission.with_s3", &statement),
resource.TestCheckResourceAttr("aws_lambda_permission.with_s3", "action", "lambda:InvokeFunction"),
Expand Down Expand Up @@ -612,7 +615,7 @@ resource "aws_lambda_permission" "third" {
principal = "events.amazonaws.com"
}`)

var testAccAWSLambdaPermissionConfig_withS3 = `
var testAccAWSLambdaPermissionConfig_withS3_tpl = `
resource "aws_lambda_permission" "with_s3" {
statement_id = "AllowExecutionFromS3"
action = "lambda:InvokeFunction"
Expand All @@ -622,7 +625,7 @@ resource "aws_lambda_permission" "with_s3" {
}
resource "aws_s3_bucket" "default" {
bucket = "tf-acc-towards-lambda"
bucket = "tf-acc-towards-lambda-%d"
acl = "private"
}
Expand Down

0 comments on commit 8a29b91

Please sign in to comment.