Git Product home page Git Product logo

14548's Introduction

####How move resource to module preserving the tf state

pre-requirements

How to run the code

  1. Open Command Line Interpreter:
OS system Operation
Windows Start menu -> Run and type cmd
Linux Start terminal
macOS Press Command - spacebar to launch Spotlight and type "Terminal," then double-click the search result.
  1. Run the following commands:
export ATLAS_TOKEN=<token>
git clone https://github.com/yaroslav-007/14548.git
cd 14548/tf-code-with-resource
terraform init
terraform apply
terraform state list
	null_resource.string
	random_string.string

We change the resource type "random_string" with name "string" to be accessed as module.

cd ../seperated_project
terraform init ###not needed if the first code was changed onplace 
terraform state list
	null_resource.string
	random_string.string <- resource that we want to move

terraform state mv random_string.string module.random_string
###terrafrom init mv <resource-type>.<name-of-resource> module.<name-of-module>)
terraform state list
	module.random_string.random_string.string
	null_resource.string

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.

random_string.string: Refreshing state... (ID: )
null_resource.string: Refreshing state... (ID: )

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

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed

14548's People

Contributors

yaroslav-007 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.