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: Refresh aws_autoscaling_schedule from state when autoscaling_group not found #12312

Merged
merged 1 commit into from
Feb 28, 2017

Conversation

stack72
Copy link
Contributor

@stack72 stack72 commented Feb 28, 2017

Fixes: #12279

When manually deleting an autoscaling_group from the console, a
terraform plan would look as follows:

% terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

aws_launch_configuration.foobar: Refreshing state... (ID: test-0096cf26c7eebdc9fcb5bd1837)
aws_autoscaling_group.foobar: Refreshing state... (ID: test)
aws_autoscaling_schedule.foobar: Refreshing state... (ID: foobar)
Error refreshing state: 1 error(s) occurred:

* aws_autoscaling_schedule.foobar: aws_autoscaling_schedule.foobar: Error retrieving Autoscaling Scheduled Actions: ValidationError: Group test not found
	status code: 400, request id: 093e9ed5-fe01-11e6-b990-1f64334b3a10

After this patch:

% terraform plan                                                                                                                          ✹ ✭
[WARN] /Users/stacko/Code/go/bin/terraform-provider-aws overrides an internal plugin for aws-provider.
  If you did not expect to see this message you will need to remove the old plugin.
  See https://www.terraform.io/docs/internals/internal-plugins.html
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

aws_launch_configuration.foobar: Refreshing state... (ID: test-0096cf26c7eebdc9fcb5bd1837)
aws_autoscaling_group.foobar: Refreshing state... (ID: test)
aws_autoscaling_schedule.foobar: Refreshing state... (ID: foobar)
The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed. Cyan entries are data sources to be read.

Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.

+ aws_autoscaling_group.foobar
    arn:                               "<computed>"
    availability_zones.#:              "1"
    availability_zones.2487133097:     "us-west-2a"
    default_cooldown:                  "<computed>"
    desired_capacity:                  "<computed>"
    force_delete:                      "true"
    health_check_grace_period:         "300"
    health_check_type:                 "ELB"
    launch_configuration:              "test-0096cf26c7eebdc9fcb5bd1837"
    load_balancers.#:                  "<computed>"
    max_size:                          "1"
    metrics_granularity:               "1Minute"
    min_size:                          "1"
    name:                              "test"
    protect_from_scale_in:             "false"
    tag.#:                             "1"
    tag.157008572.key:                 "Foo"
    tag.157008572.propagate_at_launch: "true"
    tag.157008572.value:               "foo-bar"
    termination_policies.#:            "1"
    termination_policies.0:            "OldestInstance"
    vpc_zone_identifier.#:             "<computed>"
    wait_for_capacity_timeout:         "10m"

+ aws_autoscaling_schedule.foobar
    arn:                    "<computed>"
    autoscaling_group_name: "test"
    desired_capacity:       "0"
    end_time:               "2017-12-12T06:00:00Z"
    max_size:               "1"
    min_size:               "0"
    recurrence:             "<computed>"
    scheduled_action_name:  "foobar"
    start_time:             "2017-12-11T18:00:00Z"

Plan: 2 to add, 0 to change, 0 to destroy.

…aling_group

not found

Fixes: #12279

When manually deleting an autoscaling_group from the console, a
terraform plan would look as follows:

```
% terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

aws_launch_configuration.foobar: Refreshing state... (ID: test-0096cf26c7eebdc9fcb5bd1837)
aws_autoscaling_group.foobar: Refreshing state... (ID: test)
aws_autoscaling_schedule.foobar: Refreshing state... (ID: foobar)
Error refreshing state: 1 error(s) occurred:

* aws_autoscaling_schedule.foobar: aws_autoscaling_schedule.foobar: Error retrieving Autoscaling Scheduled Actions: ValidationError: Group test not found
	status code: 400, request id: 093e9ed5-fe01-11e6-b990-1f64334b3a10

```

After this patch:

```
% terraform plan                                                                                                                          ✹ ✭
[WARN] /Users/stacko/Code/go/bin/terraform-provider-aws overrides an internal plugin for aws-provider.
  If you did not expect to see this message you will need to remove the old plugin.
  See https://www.terraform.io/docs/internals/internal-plugins.html
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

aws_launch_configuration.foobar: Refreshing state... (ID: test-0096cf26c7eebdc9fcb5bd1837)
aws_autoscaling_group.foobar: Refreshing state... (ID: test)
aws_autoscaling_schedule.foobar: Refreshing state... (ID: foobar)
The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed. Cyan entries are data sources to be read.

Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.

+ aws_autoscaling_group.foobar
    arn:                               "<computed>"
    availability_zones.#:              "1"
    availability_zones.2487133097:     "us-west-2a"
    default_cooldown:                  "<computed>"
    desired_capacity:                  "<computed>"
    force_delete:                      "true"
    health_check_grace_period:         "300"
    health_check_type:                 "ELB"
    launch_configuration:              "test-0096cf26c7eebdc9fcb5bd1837"
    load_balancers.#:                  "<computed>"
    max_size:                          "1"
    metrics_granularity:               "1Minute"
    min_size:                          "1"
    name:                              "test"
    protect_from_scale_in:             "false"
    tag.#:                             "1"
    tag.157008572.key:                 "Foo"
    tag.157008572.propagate_at_launch: "true"
    tag.157008572.value:               "foo-bar"
    termination_policies.#:            "1"
    termination_policies.0:            "OldestInstance"
    vpc_zone_identifier.#:             "<computed>"
    wait_for_capacity_timeout:         "10m"

+ aws_autoscaling_schedule.foobar
    arn:                    "<computed>"
    autoscaling_group_name: "test"
    desired_capacity:       "0"
    end_time:               "2017-12-12T06:00:00Z"
    max_size:               "1"
    min_size:               "0"
    recurrence:             "<computed>"
    scheduled_action_name:  "foobar"
    start_time:             "2017-12-11T18:00:00Z"

Plan: 2 to add, 0 to change, 0 to destroy.
```
Copy link
Contributor

@grubernaut grubernaut left a comment

Choose a reason for hiding this comment

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

LGTM!

@stack72 stack72 merged commit cf3d234 into master Feb 28, 2017
@stack72 stack72 deleted the b-aws-asg-policy-refresh branch February 28, 2017 22:08
stack72 added a commit that referenced this pull request Feb 28, 2017
…aling_group (#12312)

not found

Fixes: #12279

When manually deleting an autoscaling_group from the console, a
terraform plan would look as follows:

```
% terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

aws_launch_configuration.foobar: Refreshing state... (ID: test-0096cf26c7eebdc9fcb5bd1837)
aws_autoscaling_group.foobar: Refreshing state... (ID: test)
aws_autoscaling_schedule.foobar: Refreshing state... (ID: foobar)
Error refreshing state: 1 error(s) occurred:

* aws_autoscaling_schedule.foobar: aws_autoscaling_schedule.foobar: Error retrieving Autoscaling Scheduled Actions: ValidationError: Group test not found
	status code: 400, request id: 093e9ed5-fe01-11e6-b990-1f64334b3a10

```

After this patch:

```
% terraform plan                                                                                                                          ✹ ✭
[WARN] /Users/stacko/Code/go/bin/terraform-provider-aws overrides an internal plugin for aws-provider.
  If you did not expect to see this message you will need to remove the old plugin.
  See https://www.terraform.io/docs/internals/internal-plugins.html
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

aws_launch_configuration.foobar: Refreshing state... (ID: test-0096cf26c7eebdc9fcb5bd1837)
aws_autoscaling_group.foobar: Refreshing state... (ID: test)
aws_autoscaling_schedule.foobar: Refreshing state... (ID: foobar)
The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed. Cyan entries are data sources to be read.

Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.

+ aws_autoscaling_group.foobar
    arn:                               "<computed>"
    availability_zones.#:              "1"
    availability_zones.2487133097:     "us-west-2a"
    default_cooldown:                  "<computed>"
    desired_capacity:                  "<computed>"
    force_delete:                      "true"
    health_check_grace_period:         "300"
    health_check_type:                 "ELB"
    launch_configuration:              "test-0096cf26c7eebdc9fcb5bd1837"
    load_balancers.#:                  "<computed>"
    max_size:                          "1"
    metrics_granularity:               "1Minute"
    min_size:                          "1"
    name:                              "test"
    protect_from_scale_in:             "false"
    tag.#:                             "1"
    tag.157008572.key:                 "Foo"
    tag.157008572.propagate_at_launch: "true"
    tag.157008572.value:               "foo-bar"
    termination_policies.#:            "1"
    termination_policies.0:            "OldestInstance"
    vpc_zone_identifier.#:             "<computed>"
    wait_for_capacity_timeout:         "10m"

+ aws_autoscaling_schedule.foobar
    arn:                    "<computed>"
    autoscaling_group_name: "test"
    desired_capacity:       "0"
    end_time:               "2017-12-12T06:00:00Z"
    max_size:               "1"
    min_size:               "0"
    recurrence:             "<computed>"
    scheduled_action_name:  "foobar"
    start_time:             "2017-12-11T18:00:00Z"

Plan: 2 to add, 0 to change, 0 to destroy.
```
yanndegat pushed a commit to yanndegat/terraform that referenced this pull request Mar 13, 2017
…aling_group (hashicorp#12312)

not found

Fixes: hashicorp#12279

When manually deleting an autoscaling_group from the console, a
terraform plan would look as follows:

```
% terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

aws_launch_configuration.foobar: Refreshing state... (ID: test-0096cf26c7eebdc9fcb5bd1837)
aws_autoscaling_group.foobar: Refreshing state... (ID: test)
aws_autoscaling_schedule.foobar: Refreshing state... (ID: foobar)
Error refreshing state: 1 error(s) occurred:

* aws_autoscaling_schedule.foobar: aws_autoscaling_schedule.foobar: Error retrieving Autoscaling Scheduled Actions: ValidationError: Group test not found
	status code: 400, request id: 093e9ed5-fe01-11e6-b990-1f64334b3a10

```

After this patch:

```
% terraform plan                                                                                                                          ✹ ✭
[WARN] /Users/stacko/Code/go/bin/terraform-provider-aws overrides an internal plugin for aws-provider.
  If you did not expect to see this message you will need to remove the old plugin.
  See https://www.terraform.io/docs/internals/internal-plugins.html
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

aws_launch_configuration.foobar: Refreshing state... (ID: test-0096cf26c7eebdc9fcb5bd1837)
aws_autoscaling_group.foobar: Refreshing state... (ID: test)
aws_autoscaling_schedule.foobar: Refreshing state... (ID: foobar)
The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed. Cyan entries are data sources to be read.

Note: You didn't specify an "-out" parameter to save this plan, so when
"apply" is called, Terraform can't guarantee this is what will execute.

+ aws_autoscaling_group.foobar
    arn:                               "<computed>"
    availability_zones.#:              "1"
    availability_zones.2487133097:     "us-west-2a"
    default_cooldown:                  "<computed>"
    desired_capacity:                  "<computed>"
    force_delete:                      "true"
    health_check_grace_period:         "300"
    health_check_type:                 "ELB"
    launch_configuration:              "test-0096cf26c7eebdc9fcb5bd1837"
    load_balancers.#:                  "<computed>"
    max_size:                          "1"
    metrics_granularity:               "1Minute"
    min_size:                          "1"
    name:                              "test"
    protect_from_scale_in:             "false"
    tag.#:                             "1"
    tag.157008572.key:                 "Foo"
    tag.157008572.propagate_at_launch: "true"
    tag.157008572.value:               "foo-bar"
    termination_policies.#:            "1"
    termination_policies.0:            "OldestInstance"
    vpc_zone_identifier.#:             "<computed>"
    wait_for_capacity_timeout:         "10m"

+ aws_autoscaling_schedule.foobar
    arn:                    "<computed>"
    autoscaling_group_name: "test"
    desired_capacity:       "0"
    end_time:               "2017-12-12T06:00:00Z"
    max_size:               "1"
    min_size:               "0"
    recurrence:             "<computed>"
    scheduled_action_name:  "foobar"
    start_time:             "2017-12-11T18:00:00Z"

Plan: 2 to add, 0 to change, 0 to destroy.
```
@ghost
Copy link

ghost commented Apr 16, 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 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws_autoscaling_schedule failed when ASG was deleted
2 participants