Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AWS elasticbeanstalk "setting" inheritance #6102

Closed
dene14 opened this issue Apr 9, 2016 · 21 comments
Closed

AWS elasticbeanstalk "setting" inheritance #6102

dene14 opened this issue Apr 9, 2016 · 21 comments

Comments

@dene14
Copy link

dene14 commented Apr 9, 2016

Hi there!

We have 2 resources here

  • aws_elastic_beanstalk_environment
  • aws_elastic_beanstalk_configuration_template

both contain setting key. It's possible to define relation between them ("template_name" and "environment_id" parameters). However, it seems impossible to inherit "setting" from the parent resource.

At least I've tested it with environment configured like so:

resource "aws_elastic_beanstalk_environment" "server" {
  name = "app-prod-web"
  application = "${aws_elastic_beanstalk_application.app.name}"
  tier = "WebServer"
  template_name = "${aws_elastic_beanstalk_configuration_template.app.name}"

  setting {
    namespace = "aws:elb:loadbalancer"
    name      = "LoadBalancerHTTPPort"
    value     = "OFF"
  }
}

No settings configured for "aws_elastic_beanstalk_configuration_template.app.name" have been applied for the resource. Is it expected behaviour?

@modax
Copy link
Contributor

modax commented Apr 12, 2016

I believe this is a dupe of #6035

@dharrisio
Copy link
Contributor

Hi @dene14, which version of Terraform are you running? I think you might be seeing an issue related to #6035 as @modax mentioned. I was able to use the following config to override template settings as expected.

provider "aws" {
  region = "us-east-1"
}

resource "aws_elastic_beanstalk_application" "default" {
  name        = "tf-test-template-setting"
  description = "tf-test-desc"
}

resource "aws_elastic_beanstalk_configuration_template" "default" {
  name        = "tf-test-template-setting"
  application = "${aws_elastic_beanstalk_application.default.name}"

  solution_stack_name = "64bit Amazon Linux running Python"

  setting {
    namespace = "aws:autoscaling:launchconfiguration"
    name      = "InstanceType"
    value     = "m1.small"
  }
}

resource "aws_elastic_beanstalk_environment" "default" {
  name          = "tf-test-setting-override"
  application   = "${aws_elastic_beanstalk_application.default.name}"
  template_name = "${aws_elastic_beanstalk_configuration_template.default.name}"

  setting {
    namespace = "aws:autoscaling:launchconfiguration"
    name      = "InstanceType"
    value     = "m1.medium"
  }
}

@tecnobrat
Copy link

@dharrisio did you use latest master in your tests, or did you use the latest release. it appears the bug was fixed after the last release so I'm going to have to wait for another release?

@dharrisio
Copy link
Contributor

@tecnobrat That is correct, I tested this off of a recent master. I think it should be fixed when 0.6.15 is released, although it is currently missing from the changelog.

@dene14
Copy link
Author

dene14 commented Apr 19, 2016

Hi guys, I'm sorry for not been attended for a while...

I was using the latest release in my tests (0.6.14). And yes, that's pretty strange that nothing related has been added to changelog of upcoming 0.6.15

@tecnobrat
Copy link

@dharrisio any idea what the timeline for 0.6.15 is? Is there milestone or specific features needed to release it?

@dharrisio
Copy link
Contributor

@tecnobrat I'm not sure exactly when it will be released, I read somewhere that it was very soon though. For a more accurate answer someone from hashicorp would need to provide that.

@stack72 any chance you could get #6035/#6043 added to the changelog?

@stack72
Copy link
Contributor

stack72 commented Apr 20, 2016

Done :) I believe the release will happen in the next day or 2 :)

@dharrisio
Copy link
Contributor

Awesome, thanks @stack72!

@dene14
Copy link
Author

dene14 commented Apr 25, 2016

@stack72 Somehow I still able to reproduce the problem with 0.6.15 :(

@stack72
Copy link
Contributor

stack72 commented Apr 25, 2016

Hi @dene14

Please can you post the error message you are getting and the config (minus secrets) that is causing the issue (if it has changed)

Paul

@tecnobrat
Copy link

I'm seeing that after creating a config template and assigning that config template to an environment using the template_name property, it seems to properly assign the template to the environment, except AWS doesn't actually load / apply that change.

I'm going to try making another modification to the template, to see if that now will kick off AWS to actually load the settings from the config template.

@tecnobrat
Copy link

Yea, after making a modification to the config template, it still doesn't trigger any sort of change on Amazon's end.

@dharrisio
Copy link
Contributor

@tecnobrat I think I see where the issue is coming from. It looks like the beanstalk environment doesn't get updated if the template changes. My guess is that the environment uses a cached version of the config template, so it might not see the changes until the environment gets updated. I would be curious to see if rebuilding the environment would cause it to pick up the new changes.

When you make changes to the config template, does the name change? It would also be interesting to see what the diff output looks like when you update something in the template.

Working on reproducing the issue, so I may have some more updates here shortly.

@tecnobrat
Copy link

@dharrisio even if I give it a brand new name, that doesn't cause an environment update on amazon's side, so its weird.

@tecnobrat
Copy link

The even more odd part, if I look at the config template via amazon's API, it shows that it is "deployed" an according to the docs that means deployed: This is the configuration that is currently deployed to the associated running environment. .. but thats clearly not the case for me.

Might be an issue on amazon's end here.

@dharrisio
Copy link
Contributor

@tecnobrat I think the issue with it not updating when the name changes is on the Terraform side of things.

Currently, testing out a few things, but I should have a pr to fix that one soon.

@tecnobrat
Copy link

@dharrisio so I applied the config template via amazon's web UI (clicked on the template, clicked load, selected my environment).

That causes this really messed up diff (obfuscated a bit):

~ module.[name].aws_elastic_beanstalk_environment.[name]
    setting.#:                    "1" => "11"
    setting.1539976252.name:      "ListenerEnabled" => ""
    setting.1539976252.namespace: "aws:elb:listener:80" => ""
    setting.1539976252.value:     "true" => ""
    setting.1623554052.name:      "" => "AUTH0_CLIENT_ID"
    setting.1623554052.namespace: "" => "aws:elasticbeanstalk:application:environment"
    setting.1623554052.value:     "" => "..."
    setting.1743092794.name:      "" => "AIRBRAKE_API_KEY"
    setting.1743092794.namespace: "" => "aws:elasticbeanstalk:application:environment"
    setting.1743092794.value:     "" => "..."
    setting.178291937.name:       "" => "SSLCertificateId"
    setting.178291937.namespace:  "" => "aws:elb:listener:443"
    setting.178291937.value:      "" => "..."
    setting.228594711.name:       "" => "InstancePort"
    setting.228594711.namespace:  "" => "aws:elb:listener:443"
    setting.228594711.value:      "" => "80"
    setting.2346705714.name:      "" => "AUTH0_DOMAIN"
    setting.2346705714.namespace: "" => "aws:elasticbeanstalk:application:environment"
    setting.2346705714.value:     "" => "..."
    setting.2534268234.name:      "" => "ListenerEnabled"
    setting.2534268234.namespace: "" => "aws:elb:listener:80"
    setting.2534268234.value:     "" => "false"
    setting.2941050488.name:      "" => "InstanceProtocol"
    setting.2941050488.namespace: "" => "aws:elb:listener:443"
    setting.2941050488.value:     "" => "HTTP"
    setting.3636816719.name:      "" => "NODE_ENV"
    setting.3636816719.namespace: "" => "aws:elasticbeanstalk:application:environment"
    setting.3636816719.value:     "" => "production"
    setting.3676636476.name:      "" => "ListenerProtocol"
    setting.3676636476.namespace: "" => "aws:elb:listener:443"
    setting.3676636476.value:     "" => "HTTPS"
    setting.595795955.name:       "" => "QUERIES_ENDPOINT"
    setting.595795955.namespace:  "" => "aws:elasticbeanstalk:application:environment"
    setting.595795955.value:      "" => "..."
    setting.891409673.name:       "" => "YURL_ENDPOINT"
    setting.891409673.namespace:  "" => "aws:elasticbeanstalk:application:environment"
    setting.891409673.value:      "" => "..."

~ module.[name].beanstalk_config.aws_elastic_beanstalk_configuration_template.template
    setting.1036703857.name:      "EvaluationPeriods" => "EvaluationPeriods"
    setting.1036703857.namespace: "aws:autoscaling:trigger" => "aws:autoscaling:trigger"
    setting.1036703857.value:     "1" => "1"
    setting.1070737494.name:      "Timeout" => "Timeout"
    setting.1070737494.namespace: "aws:elasticbeanstalk:command" => "aws:elasticbeanstalk:command"
    setting.1070737494.value:     "900" => "900"
    setting.114606543.name:       "" => "UpperThreshold"
    setting.114606543.namespace:  "" => "aws:autoscaling:trigger"
    setting.114606543.value:      "" => "75"
    setting.1220848252.name:      "Subnets" => "Subnets"
    setting.1220848252.namespace: "aws:ec2:vpc" => "aws:ec2:vpc"
    setting.1220848252.value:     "..."
    setting.1311926541.name:      "RollingUpdateEnabled" => "RollingUpdateEnabled"
    setting.1311926541.namespace: "aws:autoscaling:updatepolicy:rollingupdate" => "aws:autoscaling:updatepolicy:rollingupdate"
    setting.1311926541.value:     "true" => "true"
    setting.166461702.name:       "IamInstanceProfile" => "IamInstanceProfile"
    setting.166461702.namespace:  "aws:autoscaling:launchconfiguration" => "aws:autoscaling:launchconfiguration"
    setting.166461702.value:      "beanstalk-default" => "beanstalk-default"
    setting.1934842970.name:      "ServiceRole" => "ServiceRole"
    setting.1934842970.namespace: "aws:elasticbeanstalk:environment" => "aws:elasticbeanstalk:environment"
    setting.1934842970.value:     "beanstalk-service-role" => "beanstalk-service-role"
    setting.2207438838.name:      "MinInstancesInService" => "MinInstancesInService"
    setting.2207438838.namespace: "aws:autoscaling:updatepolicy:rollingupdate" => "aws:autoscaling:updatepolicy:rollingupdate"
    setting.2207438838.value:     "1" => "1"
    setting.2221298810.name:      "MaxBatchSize" => "MaxBatchSize"
    setting.2221298810.namespace: "aws:autoscaling:updatepolicy:rollingupdate" => "aws:autoscaling:updatepolicy:rollingupdate"
    setting.2221298810.value:     "2" => "2"
    setting.2250316057.name:      "UpperThreshold" => ""
    setting.2250316057.namespace: "aws:autoscaling:trigger" => ""
    setting.2250316057.value:     "81" => ""
    setting.2276893638.name:      "RollingUpdateType" => "RollingUpdateType"
    setting.2276893638.namespace: "aws:autoscaling:updatepolicy:rollingupdate" => "aws:autoscaling:updatepolicy:rollingupdate"
    setting.2276893638.value:     "Health" => "Health"
    setting.2396587397.name:      "MinSize" => "MinSize"
    setting.2396587397.namespace: "aws:autoscaling:asg" => "aws:autoscaling:asg"
    setting.2396587397.value:     "1" => "1"
    setting.2402433859.name:      "Period" => "Period"
    setting.2402433859.namespace: "aws:autoscaling:trigger" => "aws:autoscaling:trigger"
    setting.2402433859.value:     "5" => "5"
    setting.240742627.name:       "UpperBreachScaleIncrement" => "UpperBreachScaleIncrement"
    setting.240742627.namespace:  "aws:autoscaling:trigger" => "aws:autoscaling:trigger"
    setting.240742627.value:      "1" => "1"
    setting.2420299722.name:      "SystemType" => "SystemType"
    setting.2420299722.namespace: "aws:elasticbeanstalk:healthreporting:system" => "aws:elasticbeanstalk:healthreporting:system"
    setting.2420299722.value:     "enhanced" => "enhanced"
    setting.2488689502.name:      "VPCId" => "VPCId"
    setting.2488689502.namespace: "aws:ec2:vpc" => "aws:ec2:vpc"
    setting.2488689502.value:     "vpc-..." => "vpc-..."
    setting.2740395520.name:      "Unit" => "Unit"
    setting.2740395520.namespace: "aws:autoscaling:trigger" => "aws:autoscaling:trigger"
    setting.2740395520.value:     "Percent" => "Percent"
    setting.2781862360.name:      "LowerThreshold" => "LowerThreshold"
    setting.2781862360.namespace: "aws:autoscaling:trigger" => "aws:autoscaling:trigger"
    setting.2781862360.value:     "10" => "10"
    setting.3104016902.name:      "Timeout" => "Timeout"
    setting.3104016902.namespace: "aws:autoscaling:updatepolicy:rollingupdate" => "aws:autoscaling:updatepolicy:rollingupdate"
    setting.3104016902.value:     "PT15M" => "PT15M"
    setting.3111731957.name:      "InstanceType" => "InstanceType"
    setting.3111731957.namespace: "aws:autoscaling:launchconfiguration" => "aws:autoscaling:launchconfiguration"
    setting.3111731957.value:     "t2.micro" => "t2.micro"
    setting.3341012745.name:      "MeasureName" => "MeasureName"
    setting.3341012745.namespace: "aws:autoscaling:trigger" => "aws:autoscaling:trigger"
    setting.3341012745.value:     "CPUUtilization" => "CPUUtilization"
    setting.3402994671.name:      "Statistic" => "Statistic"
    setting.3402994671.namespace: "aws:autoscaling:trigger" => "aws:autoscaling:trigger"
    setting.3402994671.value:     "Average" => "Average"
    setting.3708017666.name:      "LowerBreachScaleIncrement" => "LowerBreachScaleIncrement"
    setting.3708017666.namespace: "aws:autoscaling:trigger" => "aws:autoscaling:trigger"
    setting.3708017666.value:     "-1" => "-1"
    setting.3929976136.name:      "BatchSize" => "BatchSize"
    setting.3929976136.namespace: "aws:elasticbeanstalk:command" => "aws:elasticbeanstalk:command"
    setting.3929976136.value:     "100" => "100"
    setting.4100247781.name:      "BreachDuration" => "BreachDuration"
    setting.4100247781.namespace: "aws:autoscaling:trigger" => "aws:autoscaling:trigger"
    setting.4100247781.value:     "5" => "5"
    setting.4205492882.name:      "DeploymentPolicy" => "DeploymentPolicy"
    setting.4205492882.namespace: "aws:elasticbeanstalk:command" => "aws:elasticbeanstalk:command"
    setting.4205492882.value:     "RollingWithAdditionalBatch" => "RollingWithAdditionalBatch"
    setting.572781550.name:       "SecurityGroups" => "SecurityGroups"
    setting.572781550.namespace:  "aws:autoscaling:launchconfiguration" => "aws:autoscaling:launchconfiguration"
    setting.572781550.value:      "sg-..." => "sg-..."
    setting.693650251.name:       "MaxSize" => "MaxSize"
    setting.693650251.namespace:  "aws:autoscaling:asg" => "aws:autoscaling:asg"
    setting.693650251.value:      "4" => "4"
    setting.698921566.name:       "ELBScheme" => "ELBScheme"
    setting.698921566.namespace:  "aws:ec2:vpc" => "aws:ec2:vpc"
    setting.698921566.value:      "internet-facing" => "internet-facing"
    setting.747815089.name:       "BatchSizeType" => "BatchSizeType"
    setting.747815089.namespace:  "aws:elasticbeanstalk:command" => "aws:elasticbeanstalk:command"
    setting.747815089.value:      "Percentage" => "Percentage"
    setting.958344415.name:       "EC2KeyName" => "EC2KeyName"
    setting.958344415.namespace:  "aws:autoscaling:launchconfiguration" => "aws:autoscaling:launchconfiguration"
    setting.958344415.value:      "Dev082015" => "Dev082015"
    setting.965499686.name:       "ELBSubnets" => "ELBSubnets"
    setting.965499686.namespace:  "aws:ec2:vpc" => "aws:ec2:vpc"
    setting.965499686.value:      "..." => "..."

Looks like loading the config template in that matter, overrides all settings, and doesn't allow you to specify them directly on the environment.

@tecnobrat
Copy link

Interestingly enough, after the apply went through, this is the current state:

image

You will notice that Add instance when > 81 is incorrect, due to:

    setting.114606543.name:       "" => "UpperThreshold"
    setting.114606543.namespace:  "" => "aws:autoscaling:trigger"
    setting.114606543.value:      "" => "75"

But all of the env vars set on the environment are back.

@stack72
Copy link
Contributor

stack72 commented Apr 26, 2016

Hi @dene14

the PR from @dharrisio that fixes this has been merged

Sorry for the issue

Paul

@stack72 stack72 closed this as completed Apr 26, 2016
@ghost
Copy link

ghost commented Apr 26, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants