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

Support terraform import of kong resources #13

Merged
merged 4 commits into from
Oct 15, 2017

Conversation

erran
Copy link
Contributor

@erran erran commented Sep 17, 2017

  • Support import of all kong terraform resources.
  • Return a more specific error for 409 Conflict
    • In the case that a user hits a conflict when creating a new resource they should use terraform import to start managing the resource through the terraform kong provider.

Known caveats:

  1. terraform import of a kong_api resource will show a "change" in the hosts.
$ terraform state rm kong_api.api
$ terraform import kong_api.api 8bb0de31-40ef-4894-8417-24a19dc78488
kong_api.api: Importing from ID "8bb0de31-40ef-4894-8417-24a19dc78488"...
kong_api.api: Import complete!
  Imported kong_api (ID: 8bb0de31-40ef-4894-8417-24a19dc78488)
kong_api.api: Refreshing state... (ID: 8bb0de31-40ef-4894-8417-24a19dc78488)

$ terraform plan -target kong_api.api
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.

kong_api.api: Refreshing state... (ID: 8bb0de31-40ef-4894-8417-24a19dc78488)

------------------------------------------------------------------------

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  ~ kong_api.api
      hosts: "" => "api.domain.com"


Plan: 0 to add, 1 to change, 0 to destroy.
  1. terraform import of credentials must use the <consumer id>/<credential id> format:
$ CONSUMER=2e2e99fd-a70a-43f2-af24-d7562ef5a9ff
$ CREDENTIAL_ID=f822cb5a-d9bf-4707-a0a9-078ed4f4ff92
$ terraform import kong_consumer_key_auth_credential.test $CONSUMER/$CREDENTIAL_ID
kong_consumer_key_auth_credential.test: Importing from ID "2e2e99fd-a70a-43f2-af24-d7562ef5a9ff/f822cb5a-d9bf-4707-a0a9-078ed4f4ff92"...
kong_consumer_key_auth_credential.test: Import complete!
  Imported kong_consumer_key_auth_credential (ID: f822cb5a-d9bf-4707-a0a9-078ed4f4ff92)
kong_consumer_key_auth_credential.test: Refreshing state... (ID: f822cb5a-d9bf-4707-a0a9-078ed4f4ff92)

Import successful!

In the case that a user hits a conflict when creating a new resource
they should use terraform import to start managing the resource through
the terraform kong provider.
The plugin response object includes an api_id field. Adding it to the
Plugin type means we can import and have api set correctly in state.
This prevents terraform from failing to call read the credential
resource (due to not having a consumer in the temporary state).
@martinivanov martinivanov merged commit 8be7cd2 into WeKnowSports:master Oct 15, 2017
@erran erran deleted the add-importers branch October 19, 2017 12:56
@erran erran mentioned this pull request Jan 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants