Skip to content

Commit

Permalink
revert env var
Browse files Browse the repository at this point in the history
  • Loading branch information
DrFaust92 authored and YakDriver committed Feb 12, 2021
1 parent 1b43d1b commit c357b30
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 107 deletions.
9 changes: 0 additions & 9 deletions aws/resource_aws_synthetics_canary.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@ func resourceAwsSyntheticsCanary() *schema.Resource {
validation.IntAtLeast(960),
),
},
"environment_variables": {
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"timeout_in_seconds": {
Type: schema.TypeInt,
Optional: true,
Expand Down Expand Up @@ -545,10 +540,6 @@ func expandAwsSyntheticsCanaryRunConfig(l []interface{}) *synthetics.CanaryRunCo
codeConfig.MemoryInMB = aws.Int64(int64(v))
}

if v, ok := m["environment_variables"].(map[string]interface{}); ok && len(v) > 0 {
codeConfig.EnvironmentVariables = stringMapToPointers(v)
}

if v, ok := m["active_tracing"].(bool); ok {
codeConfig.ActiveTracing = aws.Bool(v)
}
Expand Down
98 changes: 0 additions & 98 deletions aws/resource_aws_synthetics_canary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,53 +365,6 @@ func TestAccAWSSyntheticsCanary_runConfigTracing(t *testing.T) {
})
}

func TestAccAWSSyntheticsCanary_runConfigEnvVars(t *testing.T) {
var conf synthetics.Canary
rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(8))
resourceName := "aws_synthetics_canary.test"

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
testAccPreCheck(t)
},
Providers: testAccProviders,
CheckDestroy: testAccCheckAwsSyntheticsCanaryDestroy,
Steps: []resource.TestStep{
{
Config: testAccAWSSyntheticsCanaryRunConfigEnvVarConfig1(rName, "key1", "value1"),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAwsSyntheticsCanaryExists(resourceName, &conf),
resource.TestCheckResourceAttr(resourceName, "run_config.0.environment_variables.%", "1"),
resource.TestCheckResourceAttr(resourceName, "run_config.0.environment_variables.key1", "value1"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"zip_file", "start_canary", "run_config.0.environment_variables"},
},
{
Config: testAccAWSSyntheticsCanaryRunConfigEnvVarConfig2(rName, "key1", "value1updated", "key2", "value2"),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAwsSyntheticsCanaryExists(resourceName, &conf),
resource.TestCheckResourceAttr(resourceName, "run_config.0.environment_variables.%", "2"),
resource.TestCheckResourceAttr(resourceName, "run_config.0.environment_variables.key1", "value1updated"),
resource.TestCheckResourceAttr(resourceName, "run_config.0.environment_variables.key2", "value2"),
),
},
{
Config: testAccAWSSyntheticsCanaryRunConfigEnvVarConfig1(rName, "key2", "value2"),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckAwsSyntheticsCanaryExists(resourceName, &conf),
resource.TestCheckResourceAttr(resourceName, "run_config.0.environment_variables.%", "1"),
resource.TestCheckResourceAttr(resourceName, "run_config.0.environment_variables.key2", "value2"),
),
},
},
})
}

func TestAccAWSSyntheticsCanary_vpc(t *testing.T) {
var conf synthetics.Canary
rName := fmt.Sprintf("tf-acc-test-%s", acctest.RandString(8))
Expand Down Expand Up @@ -811,57 +764,6 @@ resource "aws_synthetics_canary" "test" {
`, rName, tracing)
}

func testAccAWSSyntheticsCanaryRunConfigEnvVarConfig1(rName, key1, value1 string) string {
return testAccAWSSyntheticsCanaryConfigBase(rName) + fmt.Sprintf(`
resource "aws_synthetics_canary" "test" {
name = %[1]q
artifact_s3_location = "s3://${aws_s3_bucket.test.bucket}/"
execution_role_arn = aws_iam_role.test.arn
handler = "exports.handler"
zip_file = "test-fixtures/lambdatest.zip"
runtime_version = "syn-nodejs-2.0"
schedule {
expression = "rate(0 minute)"
}
run_config {
timeout_in_seconds = 60
environment_variables = {
%[2]q = %[3]q
}
}
}
`, rName, key1, value1)
}

func testAccAWSSyntheticsCanaryRunConfigEnvVarConfig2(rName, key1, value1, key2, value2 string) string {
return testAccAWSSyntheticsCanaryConfigBase(rName) + fmt.Sprintf(`
resource "aws_synthetics_canary" "test" {
name = %[1]q
artifact_s3_location = "s3://${aws_s3_bucket.test.bucket}/"
execution_role_arn = aws_iam_role.test.arn
handler = "exports.handler"
zip_file = "test-fixtures/lambdatest.zip"
runtime_version = "syn-nodejs-2.0"
schedule {
expression = "rate(0 minute)"
}
run_config {
timeout_in_seconds = 60
environment_variables = {
%[2]q = %[3]q
%[4]q = %[5]q
}
}
}
`, rName, key1, value1, key2, value2)
}

func testAccAWSSyntheticsCanaryBasicConfig(rName string) string {
return testAccAWSSyntheticsCanaryConfigBase(rName) + fmt.Sprintf(`
resource "aws_synthetics_canary" "test" {
Expand Down

6 comments on commit c357b30

@sijinjosephcl
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DrFaust92 I need this support for something I am working on. Was there an issue with this implementation that you had to roll this back? Would like to contribute and try to add this back.

@anilkumarkodali
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DrFaust92 Any reason why this was reverted back?

@DrFaust92
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a temp commit that should have been squashed, this was never released.

@anilkumarkodali
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code changes seem to work as expected for setting the environment variables while creating canary. Do you plan to create a PR with the changes?

@DrFaust92
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not, feel to cherry pick the commit and try, the synthetics api does not return the env vars on read this making drift detection impossible, I opted against adding support for it.

@anilkumarkodali
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. Let me try to figure out the get-canary side of things.

Please sign in to comment.