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

provider/aws: Adding outputs for elastic_beanstalk_environment resource. #5915

Conversation

dharrisio
Copy link
Contributor

For #5798 This adds a few resource outputs for an Elastic Beanstalk Environment.

Example config using these outputs for cloudwatch:

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

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

resource "aws_elastic_beanstalk_environment" "default" {
  name                = "tf-test-name"
  application         = "${aws_elastic_beanstalk_application.default.name}"
  solution_stack_name = "64bit Amazon Linux 2015.09 v2.0.4 running Go 1.4"
  tier                = "Worker"
}

resource "aws_cloudwatch_metric_alarm" "sqs" {
  alarm_name          = "terraform-test-beanstalk-sqs"
  comparison_operator = "GreaterThanOrEqualToThreshold"
  evaluation_periods  = "1"
  metric_name         = "NumberOfMessagesSent"
  namespace           = "AWS/SQS"
  period              = "3600"
  statistic           = "Sum"
  threshold           = "100"

  dimensions {
    QueueName = "${element(split("/", aws_elastic_beanstalk_environment.default.queues.0), 4)}"
  }
}

resource "aws_cloudwatch_metric_alarm" "asg" {
  alarm_name          = "terraform-test-beanstalak-asg"
  comparison_operator = "GreaterThanOrEqualToThreshold"
  evaluation_periods  = "2"
  metric_name         = "CPUUtilization"
  namespace           = "AWS/EC2"
  period              = "120"
  statistic           = "Average"
  threshold           = "80"

  dimensions {
    AutoScalingGroupName = "${aws_elastic_beanstalk_environment.default.autoscaling_groups.0}"
  }
}

Tests:

TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSBeanstalkEnv -timeout 120m
=== RUN   TestAccAWSBeanstalkEnv_basic
--- PASS: TestAccAWSBeanstalkEnv_basic (341.29s)
=== RUN   TestAccAWSBeanstalkEnv_tier
--- PASS: TestAccAWSBeanstalkEnv_tier (535.16s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    876.455s

@stack72
Copy link
Contributor

stack72 commented Mar 31, 2016

Hi @dharrisio

Thanks for the PR. I think, if possible, it would be good to have a dedicated acceptance test that tests for the specific computer parameters you have added. The basic config test should test only the very basic that the resource needs to get working

How does this sound?

Paul

@stack72
Copy link
Contributor

stack72 commented Mar 31, 2016

Just a note, the test needs to change to 64bit Amazon Linux 2015.09 v2.0.4 running Go 1.4 as I got No Solution Stack named '64bit Amazon Linux 2015.09 v2.0.4 running Go 1.4' found.

Would it also be useful to output:

  • security_groups
  • s3 bucket

@dharrisio
Copy link
Contributor Author

@stack72 For the tests would the TestMatchResourceAttr check functions just move to another test, or is there more that needs to be tested?

For the solution stack issue, I believe what you are seeing is being caused by #5922.

For the other outputs

Thanks for the feedback!

@stack72
Copy link
Contributor

stack72 commented Mar 31, 2016

Hi @dharrisio

thanks for getting back to me. I think what is needed here is that the original basic test should exist and then another test should be added for those specific TestMatchResourceAttr should be added

This would allow us to see that the basic operation works :)

With regards to S3 bucket and security_group, let's take that outside of this for now. It's extra functionality that can be added when needed.

I am not quite sure what we can do with the test data though. That seems troublesome that we would need to look that up....

Paul

@dharrisio
Copy link
Contributor Author

@stack72 Thanks for the clarification, I'll create that other test and commit it shortly.

Totally understand the hesitation about looking up data to run the tests. One possible solution is to use an older solution stack, before they started putting versions in the names. That might work, but it might introduce some other issues. Other than that, I can't really think of any other solutions. I'll give it a try and update the other issue with the results.

@stack72
Copy link
Contributor

stack72 commented Mar 31, 2016

👍

@dharrisio dharrisio force-pushed the f-aws-elastic-beanstalk-environment-options branch from 2c55df9 to 4d20c61 Compare March 31, 2016 20:30
@dharrisio
Copy link
Contributor Author

@stack72

I updated this with a new test for the outputs and with a different solution_stack. From what I can tell the new solution stack name will fix the issue we were seeing with the previous test config. I tested it in EC2-Classic and EC2-VPC accounts and it is working in both.

TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSBeanstalk -timeout 120m
=== RUN   TestAccAWSBeanstalkApp_basic
--- PASS: TestAccAWSBeanstalkApp_basic (7.82s)
=== RUN   TestAccAWSBeanstalkConfigurationTemplate_basic
--- PASS: TestAccAWSBeanstalkConfigurationTemplate_basic (12.10s)
=== RUN   TestAccAWSBeanstalkConfigurationTemplate_VPC
--- PASS: TestAccAWSBeanstalkConfigurationTemplate_VPC (16.25s)
=== RUN   TestAccAWSBeanstalkEnv_basic
--- PASS: TestAccAWSBeanstalkEnv_basic (351.47s)
=== RUN   TestAccAWSBeanstalkEnv_tier
--- PASS: TestAccAWSBeanstalkEnv_tier (529.03s)
=== RUN   TestAccAWSBeanstalkEnv_outputs
--- PASS: TestAccAWSBeanstalkEnv_outputs (321.39s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    1238.072s

@dharrisio dharrisio force-pushed the f-aws-elastic-beanstalk-environment-options branch from 4d20c61 to 5a72efa Compare April 1, 2016 19:28
@dharrisio dharrisio force-pushed the f-aws-elastic-beanstalk-environment-options branch from 5a72efa to c3a6cf0 Compare April 1, 2016 19:58
@dharrisio
Copy link
Contributor Author

@stack72 I've rebased this pr as well. Let me know if you need anything else here.

Thanks!

@stack72
Copy link
Contributor

stack72 commented Apr 1, 2016

Hi @dharrisio

this is great! thanks so much for taking care of all of this :)

P.

@stack72 stack72 merged commit 4c2738a into hashicorp:master Apr 1, 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.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants