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/azurerm: fixing a bug refreshing the azurerm_redis_cache #13899

Merged
merged 2 commits into from
Apr 24, 2017

Conversation

tombuildsstuff
Copy link
Contributor

Currently, attempting to plan when an azurerm_redis_cache resource has been deleted in the portal - Terraform returns an error:

$ envchain azurerm terraform plan -refresh
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.

azurerm_resource_group.test: Refreshing state... (ID: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/tharvey-devrg)
azurerm_redis_cache.redis: Refreshing state... (ID: /subscriptions/00000000-0000-0000-0000-...providers/Microsoft.Cache/Redis/redis0)
Error refreshing state: 1 error(s) occurred:

* azurerm_redis_cache.redis: azurerm_redis_cache.redis: Error making Read request on Azure Redis Cache redis0: redis.GroupClient#Get: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="ResourceNotFound" Message="The Resource 'Microsoft.Cache/Redis/redis0' under resource group 'tharvey-devrg' was not found.

This PR checks for a HTTP Not Found result - and removes it from the state if it doesn't exist:

$ envchain azurerm terraform plan -refresh
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.

azurerm_resource_group.test: Refreshing state... (ID: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/tharvey-devrg)
azurerm_redis_cache.redis: Refreshing state... (ID: /subscriptions/00000000-0000-0000-0000-...providers/Microsoft.Cache/Redis/redis0)
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.

+ azurerm_redis_cache.redis
    capacity:                                 "1"
    enable_non_ssl_port:                      "false"
    family:                                   "C"
    hostname:                                 "<computed>"
    location:                                 "westeurope"
    name:                                     "redis0"
    port:                                     "<computed>"
    primary_access_key:                       "<computed>"
    redis_configuration.#:                    "1"
    redis_configuration.0.maxclients:         "1000"
    redis_configuration.0.maxmemory_delta:    "<computed>"
    redis_configuration.0.maxmemory_policy:   "volatile-lru"
    redis_configuration.0.maxmemory_reserved: "<computed>"
    resource_group_name:                      "tharvey-devrg"
    secondary_access_key:                     "<computed>"
    sku_name:                                 "Standard"
    ssl_port:                                 "<computed>"
    tags.%:                                   "2"
    tags.environment:                         "production"
    tags.role:                                "redis"


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

Fixes #13896

@tombuildsstuff
Copy link
Contributor Author

Tests pass:
screen shot 2017-04-24 at 12 15 24

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, minor nit to add a comment on why delaying the error catch is necessary, but looks good otherwise. 💯

@tombuildsstuff tombuildsstuff merged commit a7401ad into master Apr 24, 2017
@tombuildsstuff tombuildsstuff deleted the azurerm-redis-bug branch April 24, 2017 15:17
tombuildsstuff added a commit that referenced this pull request Apr 24, 2017
@ghost
Copy link

ghost commented Apr 13, 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 13, 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.

Refreshing the state of azurerm_redis_cache resource
2 participants