Fix TestAccAWSEcsService_withAlb
This commit is contained in:
parent
1aa08b0519
commit
9cd1dbf671
|
@ -243,13 +243,14 @@ func TestAccAWSEcsService_withEcsClusterName(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAWSEcsService_withAlb(t *testing.T) {
|
func TestAccAWSEcsService_withAlb(t *testing.T) {
|
||||||
|
rString := acctest.RandString(10)
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
CheckDestroy: testAccCheckAWSEcsServiceDestroy,
|
CheckDestroy: testAccCheckAWSEcsServiceDestroy,
|
||||||
Steps: []resource.TestStep{
|
Steps: []resource.TestStep{
|
||||||
{
|
{
|
||||||
Config: testAccAWSEcsServiceWithAlb,
|
Config: testAccAWSEcsServiceWithAlb(rString),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSEcsServiceExists("aws_ecs_service.with_alb"),
|
testAccCheckAWSEcsServiceExists("aws_ecs_service.with_alb"),
|
||||||
),
|
),
|
||||||
|
@ -874,7 +875,8 @@ resource "aws_ecs_service" "jenkins" {
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
var testAccAWSEcsServiceWithAlb = `
|
func testAccAWSEcsServiceWithAlb(rString string) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
data "aws_availability_zones" "available" {}
|
data "aws_availability_zones" "available" {}
|
||||||
|
|
||||||
resource "aws_vpc" "main" {
|
resource "aws_vpc" "main" {
|
||||||
|
@ -889,7 +891,7 @@ resource "aws_subnet" "main" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_ecs_cluster" "main" {
|
resource "aws_ecs_cluster" "main" {
|
||||||
name = "terraform_acc_test_ecs_15"
|
name = "terraform_acc_test_ecs_%s"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_ecs_task_definition" "with_lb_changes" {
|
resource "aws_ecs_task_definition" "with_lb_changes" {
|
||||||
|
@ -914,7 +916,7 @@ DEFINITION
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_iam_role" "ecs_service" {
|
resource "aws_iam_role" "ecs_service" {
|
||||||
name = "tf_acc_test_15_role"
|
name = "tf_acc_test_%s_role"
|
||||||
assume_role_policy = <<EOF
|
assume_role_policy = <<EOF
|
||||||
{
|
{
|
||||||
"Version": "2008-10-17",
|
"Version": "2008-10-17",
|
||||||
|
@ -933,7 +935,7 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_iam_role_policy" "ecs_service" {
|
resource "aws_iam_role_policy" "ecs_service" {
|
||||||
name = "tf_acc_test_15_policy"
|
name = "tf_acc_test_%s_policy"
|
||||||
role = "${aws_iam_role.ecs_service.name}"
|
role = "${aws_iam_role.ecs_service.name}"
|
||||||
policy = <<EOF
|
policy = <<EOF
|
||||||
{
|
{
|
||||||
|
@ -957,16 +959,22 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_alb_target_group" "test" {
|
resource "aws_alb_target_group" "test" {
|
||||||
name = "tf-acc-test-ecs-ghost"
|
name = "tf-acc-test-ecs-ghost-%s"
|
||||||
port = 80
|
port = 80
|
||||||
protocol = "HTTP"
|
protocol = "HTTP"
|
||||||
vpc_id = "${aws_vpc.main.id}"
|
vpc_id = "${aws_vpc.main.id}"
|
||||||
|
tags {
|
||||||
|
Name = "TestAccAWSEcsService_withAlb"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_alb" "main" {
|
resource "aws_alb" "main" {
|
||||||
name = "tf-acc-test-test-alb-ecs"
|
name = "tf-acc-test-alb-ecs-%s"
|
||||||
internal = true
|
internal = true
|
||||||
subnets = ["${aws_subnet.main.*.id}"]
|
subnets = ["${aws_subnet.main.*.id}"]
|
||||||
|
tags {
|
||||||
|
Name = "TestAccAWSEcsService_withAlb"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_alb_listener" "front_end" {
|
resource "aws_alb_listener" "front_end" {
|
||||||
|
@ -981,7 +989,7 @@ resource "aws_alb_listener" "front_end" {
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_ecs_service" "with_alb" {
|
resource "aws_ecs_service" "with_alb" {
|
||||||
name = "tf-acc-test-ecs-ghost"
|
name = "tf-acc-test-ecs-ghost-%s"
|
||||||
cluster = "${aws_ecs_cluster.main.id}"
|
cluster = "${aws_ecs_cluster.main.id}"
|
||||||
task_definition = "${aws_ecs_task_definition.with_lb_changes.arn}"
|
task_definition = "${aws_ecs_task_definition.with_lb_changes.arn}"
|
||||||
desired_count = 1
|
desired_count = 1
|
||||||
|
@ -998,4 +1006,5 @@ resource "aws_ecs_service" "with_alb" {
|
||||||
"aws_alb_listener.front_end"
|
"aws_alb_listener.front_end"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
`
|
`, rString, rString, rString, rString, rString, rString)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue