mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Randomize mongodb names
This commit is contained in:
parent
2db0e12e63
commit
15aabe93c3
@ -85,20 +85,21 @@ func TestParseTaskDefinition(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAWSEcsServiceWithARN(t *testing.T) {
|
func TestAccAWSEcsServiceWithARN(t *testing.T) {
|
||||||
|
rInt := acctest.RandInt()
|
||||||
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: testAccAWSEcsService,
|
Config: testAccAWSEcsService(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"),
|
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
Config: testAccAWSEcsServiceModified,
|
Config: testAccAWSEcsServiceModified(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"),
|
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"),
|
||||||
),
|
),
|
||||||
@ -181,13 +182,14 @@ func TestAccAWSEcsService_withIamRole(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAWSEcsService_withDeploymentValues(t *testing.T) {
|
func TestAccAWSEcsService_withDeploymentValues(t *testing.T) {
|
||||||
|
rInt := acctest.RandInt()
|
||||||
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: testAccAWSEcsServiceWithDeploymentValues,
|
Config: testAccAWSEcsServiceWithDeploymentValues(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"),
|
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
@ -262,20 +264,21 @@ func TestAccAWSEcsService_withAlb(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAWSEcsServiceWithPlacementStrategy(t *testing.T) {
|
func TestAccAWSEcsServiceWithPlacementStrategy(t *testing.T) {
|
||||||
|
rInt := acctest.RandInt()
|
||||||
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: testAccAWSEcsService,
|
Config: testAccAWSEcsService(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"),
|
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"),
|
||||||
resource.TestCheckResourceAttr("aws_ecs_service.mongo", "placement_strategy.#", "0"),
|
resource.TestCheckResourceAttr("aws_ecs_service.mongo", "placement_strategy.#", "0"),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Config: testAccAWSEcsServiceWithPlacementStrategy,
|
Config: testAccAWSEcsServiceWithPlacementStrategy(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"),
|
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"),
|
||||||
resource.TestCheckResourceAttr("aws_ecs_service.mongo", "placement_strategy.#", "1"),
|
resource.TestCheckResourceAttr("aws_ecs_service.mongo", "placement_strategy.#", "1"),
|
||||||
@ -286,13 +289,14 @@ func TestAccAWSEcsServiceWithPlacementStrategy(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAWSEcsServiceWithPlacementConstraints(t *testing.T) {
|
func TestAccAWSEcsServiceWithPlacementConstraints(t *testing.T) {
|
||||||
|
rInt := acctest.RandInt()
|
||||||
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: testAccAWSEcsServiceWithPlacementConstraint,
|
Config: testAccAWSEcsServiceWithPlacementConstraint(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"),
|
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"),
|
||||||
resource.TestCheckResourceAttr("aws_ecs_service.mongo", "placement_constraints.#", "1"),
|
resource.TestCheckResourceAttr("aws_ecs_service.mongo", "placement_constraints.#", "1"),
|
||||||
@ -303,13 +307,14 @@ func TestAccAWSEcsServiceWithPlacementConstraints(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestAccAWSEcsServiceWithPlacementConstraints_emptyExpression(t *testing.T) {
|
func TestAccAWSEcsServiceWithPlacementConstraints_emptyExpression(t *testing.T) {
|
||||||
|
rInt := acctest.RandInt()
|
||||||
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: testAccAWSEcsServiceWithPlacementConstraintEmptyExpression,
|
Config: testAccAWSEcsServiceWithPlacementConstraintEmptyExpression(rInt),
|
||||||
Check: resource.ComposeTestCheckFunc(
|
Check: resource.ComposeTestCheckFunc(
|
||||||
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"),
|
testAccCheckAWSEcsServiceExists("aws_ecs_service.mongo"),
|
||||||
resource.TestCheckResourceAttr("aws_ecs_service.mongo", "placement_constraints.#", "1"),
|
resource.TestCheckResourceAttr("aws_ecs_service.mongo", "placement_constraints.#", "1"),
|
||||||
@ -366,9 +371,10 @@ func testAccCheckAWSEcsServiceExists(name string) resource.TestCheckFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var testAccAWSEcsService = `
|
func testAccAWSEcsService(rInt int) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_ecs_cluster" "default" {
|
resource "aws_ecs_cluster" "default" {
|
||||||
name = "terraformecstest1"
|
name = "terraformecstest%d"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_ecs_task_definition" "mongo" {
|
resource "aws_ecs_task_definition" "mongo" {
|
||||||
@ -387,16 +393,18 @@ DEFINITION
|
|||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_ecs_service" "mongo" {
|
resource "aws_ecs_service" "mongo" {
|
||||||
name = "mongodb"
|
name = "mongodb-%d"
|
||||||
cluster = "${aws_ecs_cluster.default.id}"
|
cluster = "${aws_ecs_cluster.default.id}"
|
||||||
task_definition = "${aws_ecs_task_definition.mongo.arn}"
|
task_definition = "${aws_ecs_task_definition.mongo.arn}"
|
||||||
desired_count = 1
|
desired_count = 1
|
||||||
}
|
}
|
||||||
`
|
`, rInt, rInt)
|
||||||
|
}
|
||||||
|
|
||||||
var testAccAWSEcsServiceModified = `
|
func testAccAWSEcsServiceModified(rInt int) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_ecs_cluster" "default" {
|
resource "aws_ecs_cluster" "default" {
|
||||||
name = "terraformecstest1"
|
name = "terraformecstest%d"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_ecs_task_definition" "mongo" {
|
resource "aws_ecs_task_definition" "mongo" {
|
||||||
@ -415,16 +423,18 @@ DEFINITION
|
|||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_ecs_service" "mongo" {
|
resource "aws_ecs_service" "mongo" {
|
||||||
name = "mongodb"
|
name = "mongodb-%d"
|
||||||
cluster = "${aws_ecs_cluster.default.id}"
|
cluster = "${aws_ecs_cluster.default.id}"
|
||||||
task_definition = "${aws_ecs_task_definition.mongo.arn}"
|
task_definition = "${aws_ecs_task_definition.mongo.arn}"
|
||||||
desired_count = 2
|
desired_count = 2
|
||||||
}
|
}
|
||||||
`
|
`, rInt, rInt)
|
||||||
|
}
|
||||||
|
|
||||||
var testAccAWSEcsServiceWithPlacementStrategy = `
|
func testAccAWSEcsServiceWithPlacementStrategy(rInt int) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_ecs_cluster" "default" {
|
resource "aws_ecs_cluster" "default" {
|
||||||
name = "terraformecstest1"
|
name = "terraformecstest%d"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_ecs_task_definition" "mongo" {
|
resource "aws_ecs_task_definition" "mongo" {
|
||||||
@ -443,7 +453,7 @@ DEFINITION
|
|||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_ecs_service" "mongo" {
|
resource "aws_ecs_service" "mongo" {
|
||||||
name = "mongodb"
|
name = "mongodb-%d"
|
||||||
cluster = "${aws_ecs_cluster.default.id}"
|
cluster = "${aws_ecs_cluster.default.id}"
|
||||||
task_definition = "${aws_ecs_task_definition.mongo.arn}"
|
task_definition = "${aws_ecs_task_definition.mongo.arn}"
|
||||||
desired_count = 1
|
desired_count = 1
|
||||||
@ -452,17 +462,19 @@ resource "aws_ecs_service" "mongo" {
|
|||||||
field = "memory"
|
field = "memory"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`, rInt, rInt)
|
||||||
|
|
||||||
var testAccAWSEcsServiceWithPlacementConstraint = `
|
|
||||||
resource "aws_ecs_cluster" "default" {
|
|
||||||
name = "terraformecstest21"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_ecs_task_definition" "mongo" {
|
func testAccAWSEcsServiceWithPlacementConstraint(rInt int) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
|
resource "aws_ecs_cluster" "default" {
|
||||||
|
name = "terraformecstest%d"
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "aws_ecs_task_definition" "mongo" {
|
||||||
family = "mongodb"
|
family = "mongodb"
|
||||||
container_definitions = <<DEFINITION
|
container_definitions = <<DEFINITION
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"cpu": 128,
|
"cpu": 128,
|
||||||
"essential": true,
|
"essential": true,
|
||||||
@ -470,12 +482,12 @@ resource "aws_ecs_task_definition" "mongo" {
|
|||||||
"memory": 128,
|
"memory": 128,
|
||||||
"name": "mongodb"
|
"name": "mongodb"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
DEFINITION
|
DEFINITION
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_ecs_service" "mongo" {
|
resource "aws_ecs_service" "mongo" {
|
||||||
name = "mongodb"
|
name = "mongodb-%d"
|
||||||
cluster = "${aws_ecs_cluster.default.id}"
|
cluster = "${aws_ecs_cluster.default.id}"
|
||||||
task_definition = "${aws_ecs_task_definition.mongo.arn}"
|
task_definition = "${aws_ecs_task_definition.mongo.arn}"
|
||||||
desired_count = 1
|
desired_count = 1
|
||||||
@ -483,12 +495,14 @@ resource "aws_ecs_service" "mongo" {
|
|||||||
type = "memberOf"
|
type = "memberOf"
|
||||||
expression = "attribute:ecs.availability-zone in [us-west-2a, us-west-2b]"
|
expression = "attribute:ecs.availability-zone in [us-west-2a, us-west-2b]"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
`, rInt, rInt)
|
||||||
}
|
}
|
||||||
`
|
|
||||||
|
|
||||||
var testAccAWSEcsServiceWithPlacementConstraintEmptyExpression = `
|
func testAccAWSEcsServiceWithPlacementConstraintEmptyExpression(rInt int) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_ecs_cluster" "default" {
|
resource "aws_ecs_cluster" "default" {
|
||||||
name = "terraformecstest212"
|
name = "terraformecstest%d"
|
||||||
}
|
}
|
||||||
resource "aws_ecs_task_definition" "mongo" {
|
resource "aws_ecs_task_definition" "mongo" {
|
||||||
family = "mongodb"
|
family = "mongodb"
|
||||||
@ -505,7 +519,7 @@ resource "aws_ecs_task_definition" "mongo" {
|
|||||||
DEFINITION
|
DEFINITION
|
||||||
}
|
}
|
||||||
resource "aws_ecs_service" "mongo" {
|
resource "aws_ecs_service" "mongo" {
|
||||||
name = "mongodb"
|
name = "mongodb-%d"
|
||||||
cluster = "${aws_ecs_cluster.default.id}"
|
cluster = "${aws_ecs_cluster.default.id}"
|
||||||
task_definition = "${aws_ecs_task_definition.mongo.arn}"
|
task_definition = "${aws_ecs_task_definition.mongo.arn}"
|
||||||
desired_count = 1
|
desired_count = 1
|
||||||
@ -513,7 +527,8 @@ resource "aws_ecs_service" "mongo" {
|
|||||||
type = "distinctInstance"
|
type = "distinctInstance"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`, rInt, rInt)
|
||||||
|
}
|
||||||
|
|
||||||
var testAccAWSEcsService_withIamRole = `
|
var testAccAWSEcsService_withIamRole = `
|
||||||
resource "aws_ecs_cluster" "main" {
|
resource "aws_ecs_cluster" "main" {
|
||||||
@ -609,9 +624,10 @@ resource "aws_ecs_service" "ghost" {
|
|||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
var testAccAWSEcsServiceWithDeploymentValues = `
|
func testAccAWSEcsServiceWithDeploymentValues(rInt int) string {
|
||||||
|
return fmt.Sprintf(`
|
||||||
resource "aws_ecs_cluster" "default" {
|
resource "aws_ecs_cluster" "default" {
|
||||||
name = "terraformecstest1"
|
name = "terraformecstest-%d"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_ecs_task_definition" "mongo" {
|
resource "aws_ecs_task_definition" "mongo" {
|
||||||
@ -630,12 +646,13 @@ DEFINITION
|
|||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_ecs_service" "mongo" {
|
resource "aws_ecs_service" "mongo" {
|
||||||
name = "mongodb"
|
name = "mongodb-%d"
|
||||||
cluster = "${aws_ecs_cluster.default.id}"
|
cluster = "${aws_ecs_cluster.default.id}"
|
||||||
task_definition = "${aws_ecs_task_definition.mongo.arn}"
|
task_definition = "${aws_ecs_task_definition.mongo.arn}"
|
||||||
desired_count = 1
|
desired_count = 1
|
||||||
}
|
}
|
||||||
`
|
`, rInt, rInt)
|
||||||
|
}
|
||||||
|
|
||||||
var tpl_testAccAWSEcsService_withLbChanges = `
|
var tpl_testAccAWSEcsService_withLbChanges = `
|
||||||
resource "aws_ecs_cluster" "main" {
|
resource "aws_ecs_cluster" "main" {
|
||||||
|
Loading…
Reference in New Issue
Block a user