Commit 0e1d7a28 authored by Daisuke Fujita's avatar Daisuke Fujita

Increment tfstate serial

parent 6407d9d3
......@@ -19,6 +19,7 @@ module Terraforming
def generate_tfstate(resources, tfstate_base = nil)
tfstate = tfstate_base || tfstate_skeleton
tfstate["serial"] = tfstate["serial"] + 1
tfstate["modules"][0]["resources"] = tfstate["modules"][0]["resources"].merge(resources)
JSON.pretty_generate(tfstate)
end
......@@ -36,7 +37,7 @@ module Terraforming
def tfstate_skeleton
{
"version" => 1,
"serial" => 1,
"serial" => 0,
"modules" => [
{
"path" => [
......
......@@ -179,7 +179,7 @@ resource "aws_db_parameter_group" "default-postgres9-4" {
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -137,7 +137,7 @@ resource "aws_db_security_group" "sgfoobar" {
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -125,7 +125,7 @@ resource "aws_db_subnet_group" "fuga" {
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -189,7 +189,7 @@ resource "aws_instance" "hoge" {
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -289,7 +289,7 @@ resource "aws_elb" "fuga" {
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -141,7 +141,7 @@ POLICY
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -97,7 +97,7 @@ resource "aws_iam_group" "fuga" {
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -110,7 +110,7 @@ resource "aws_iam_instance_profile" "fuga_profile" {
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -150,7 +150,7 @@ POLICY
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -146,7 +146,7 @@ POLICY
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -131,7 +131,7 @@ POLICY
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -143,7 +143,7 @@ POLICY
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -99,7 +99,7 @@ resource "aws_iam_user" "fuga" {
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -193,7 +193,7 @@ resource "aws_network_acl" "fuga" {
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -178,7 +178,7 @@ resource "aws_db_instance" "hogedb" {
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -151,7 +151,7 @@ resource "aws_route53_record" "www-fuga-net" {
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -149,7 +149,7 @@ resource "aws_route53_zone" "fuga-net" {
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -94,7 +94,7 @@ resource "aws_s3_bucket" "fuga" {
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -217,7 +217,7 @@ resource "aws_security_group" "sg-5678efgh-fuga" {
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -123,7 +123,7 @@ resource "aws_subnet" "fuga" {
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
......@@ -135,7 +135,7 @@ resource "aws_vpc" "fuga" {
it "should generate tfstate and merge it to existing tfstate" do
expect(described_class.tfstate(client: client, tfstate_base: tfstate_fixture)).to eq JSON.pretty_generate({
"version" => 1,
"serial" => 88,
"serial" => 89,
"remote" => {
"type" => "s3",
"config" => { "bucket" => "terraforming-tfstate", "key" => "tf" }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment