Skip to content

Commit

Permalink
lint: Fixing docs and linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tfhartmann committed Oct 9, 2019
1 parent 4442c2a commit 767a17f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/upgrading_to_v2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Because v2.x changed how the subnet resource is iterated on, resources in Terraf

## Migration Instructions

- Upgrade to the new version of this module.
- Upgrade to the new version of this module.

if you run `terraform plan` at this point. Terraform will inform you that it will attempt to delete and recreate your existing subnets. This is almost certainly not the behavior you want. For example:

Expand Down
19 changes: 16 additions & 3 deletions scripts/migrate.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
#!/usr/bin/env bash
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# shellcheck shell=bash
# Output Terraform Commands to migrate to new subnet config
set -e
set -o pipefail

if [[ "$MODULE_NAME" ]]; then
NAME=$(terraform state list | grep ${MODULE_NAME}.google_compute_network.network | sed 's/.google_compute_network.network//')
for x in $(terraform state list | grep ${NAME}.google_compute_subnetwork.subnetwork); do
ID=$(terraform state show $x | grep id | grep -v ip_cidr_range | awk '{ print $3 }'| tr -d '"')
NAME=$(terraform state list | grep "${MODULE_NAME}".google_compute_network.network | sed 's/.google_compute_network.network//')
for x in $(terraform state list | grep "${NAME}".google_compute_subnetwork.subnetwork); do
ID=$(terraform state show "$x" | grep id | grep -v ip_cidr_range | awk '{ print $3 }'| tr -d '"')
echo "terraform state mv $x ${NAME}.google_compute_subnetwork.subnetwork[\\\"${ID}\\\"]"
done
else
Expand Down

0 comments on commit 767a17f

Please sign in to comment.