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

r/aws_elastic_beanstalk_application: Add appversion_lifecycle #1907

Merged

Conversation

mfenniak
Copy link
Contributor

@mfenniak mfenniak commented Oct 16, 2017

Adds appversion_lifecycle configuration under aws_elastic_beanstalk_application resource to configure automatic cleanup of application versions.

Addresses issue #537.

@radeksimko radeksimko added the enhancement Requests to existing resources that expand the functionality or scope. label Oct 16, 2017
@mfenniak mfenniak force-pushed the issue_537_ebstalk_appversion_lifecycle branch from 7b21f23 to 18b34de Compare November 12, 2017 04:00
@mfenniak mfenniak changed the title [WIP] r/aws_elastic_beanstalk_application: Add appversion_lifecycle r/aws_elastic_beanstalk_application: Add appversion_lifecycle Nov 12, 2017
@radeksimko radeksimko added the size/L Managed by automation to categorize the size of a PR. label Nov 15, 2017
@bflad bflad added the service/elasticbeanstalk Issues and PRs that pertain to the elasticbeanstalk service. label Jan 28, 2018
@bflad bflad added this to the v1.13.0 milestone Mar 20, 2018
@bflad bflad modified the milestones: v1.13.0, v1.14.0 Mar 29, 2018
@bflad bflad modified the milestones: v1.14.0, v1.15.0 Apr 6, 2018
@bflad bflad modified the milestones: v1.15.0, v1.16.0 Apr 18, 2018
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Apr 24, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Hi @mfenniak 👋 Very sorry for the delayed review of this PR 😅 after rebasing and randomizing the test resource naming (we run our acceptance testing concurrently), this LGTM.

make testacc TEST=./aws TESTARGS='-run=TestAccAWSBeanstalkApp'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSBeanstalkApp -timeout 120m
=== RUN   TestAccAWSBeanstalkApp_basic
--- PASS: TestAccAWSBeanstalkApp_basic (15.12s)
=== RUN   TestAccAWSBeanstalkApp_appversionlifecycle
--- PASS: TestAccAWSBeanstalkApp_appversionlifecycle (36.71s)
=== RUN   TestAccAWSBeanstalkAppVersion_basic
--- PASS: TestAccAWSBeanstalkAppVersion_basic (32.75s)
=== RUN   TestAccAWSBeanstalkAppVersion_duplicateLabels
--- PASS: TestAccAWSBeanstalkAppVersion_duplicateLabels (32.79s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	117.403s

@bflad bflad merged commit 3f6050a into hashicorp:master Apr 24, 2018
bflad added a commit that referenced this pull request Apr 24, 2018
@bflad
Copy link
Contributor

bflad commented Apr 25, 2018

This has been released in version 1.16.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@mfenniak
Copy link
Contributor Author

Thanks for the review, merge, and quick release bflad! Appreciate it.

@ozbillwang
Copy link

ozbillwang commented Nov 14, 2018

@mfenniak

I recently applied the change with appversion_lifecycle with max_count to 50

But I found there are still more than 100 versions, I wait for one week, total versions doesn't reduce to 50 automatically.

Could you please confirm if this feature really works or not?

provider "aws" {
  region = "${var.AWS_DEFAULT_REGION}"
}

data "aws_iam_role" "eb" {
  name = "AWSServiceRoleForElasticBeanstalk"
}

resource "aws_elastic_beanstalk_application" "ebapp" {
  name        = "${var.APP_NAME}"
  description = "Beanstalk application for ${var.APP_NAME}"

  appversion_lifecycle {
    service_role          = "${data.aws_iam_role.eb.arn}"
    max_count             = 50
    delete_source_from_s3 = true
  }
}

terraform version is 0.11.7
aws provider is latest.

Can you confirm what policies I should assign to iam role AWSServiceRoleForElasticBeanstalk?

@mfenniak
Copy link
Contributor Author

@ozbillwang Hi Bill; I can confirm that this capability actually works on AWS. If it is appearing in the application's "Settings" page on the AWS Console, it is likely a problem with your IAM role. Other than this, if it appears in the AWS Console, but it doesn't work, it's not a problem with the terraform side of this equation, and I'd suggest you reach out to AWS support for further help. :-)

Here's a working IAM role policy that my application uses:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "",
            "Effect": "Allow",
            "Action": "elasticbeanstalk:DeleteApplicationVersion",
            "Resource": "arn:aws:elasticbeanstalk:*:*:applicationversion/*/*"
        },
        {
            "Sid": "",
            "Effect": "Allow",
            "Action": [
                "s3:GetObject",
                "s3:DeleteObject"
            ],
            "Resource": [
                "arn:aws:s3:::elasticbeanstalk-*/*",
                "arn:aws:s3:::elasticbeanstalk-*"
            ]
        }
    ]
}

@ghost
Copy link

ghost commented Apr 2, 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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/elasticbeanstalk Issues and PRs that pertain to the elasticbeanstalk service. size/L Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants