Skip to content

Instantly share code, notes, and snippets.

@radeksimko
Last active August 29, 2016 10:36
Show Gist options
  • Save radeksimko/961c544ab114b72c665392ed4b2ce786 to your computer and use it in GitHub Desktop.
Save radeksimko/961c544ab114b72c665392ed4b2ce786 to your computer and use it in GitHub Desktop.

Config to start with

resource "aws_cloudformation_stack" "network" {
  name = "tf-networking-stack"
  on_failure = "DO_NOTHING"
  template_body = <<STACK
{
  "Resources" : {
    "myvpc": {
      "Type" : "AWS::EC2::VPC",
      "Properties" : {
        "CidrBlock" : "256.0.0.0/16",
        "Tags" : [
          {"Key": "Name", "Value": "Primary_CF_VPC"}
        ]
      }
    }
  }
}
STACK
}

on_failure = "DO_NOTHING"

$ terraform apply
aws_cloudformation_stack.network: Creating...
  name:          "" => "tf-networking-stack"
  on_failure:    "" => "DO_NOTHING"
  outputs.%:     "" => "<computed>"
  parameters.%:  "" => "<computed>"
  policy_body:   "" => "<computed>"
  template_body: "" => "{\"Resources\":{\"myvpc\":{\"Properties\":{\"CidrBlock\":\"256.0.0.0/16\",\"Tags\":[{\"Key\":\"Name\",\"Value\":\"Primary_CF_VPC\"}]},\"Type\":\"AWS::EC2::VPC\"}}}"
Error applying plan:

1 error(s) occurred:

* aws_cloudformation_stack.network: CREATE_FAILED: ["The following resource(s) failed to create: [myvpc]. " "Value (256.0.0.0/16) for parameter cidrBlock is invalid. This is not a valid CIDR block."]

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
$ terraform destroy
Do you really want to destroy?
  Terraform will delete all your managed infrastructure.
  There is no undo. Only 'yes' will be accepted to confirm.

  Enter a value: yes

aws_cloudformation_stack.network: Refreshing state... (ID: arn:aws:cloudformation:us-west-2:112336751141:stack/tf-networking-stack/57669840-6dd2-11e6-ace4-51d5ca789e82)
aws_cloudformation_stack.network: Destroying...
aws_cloudformation_stack.network: Still destroying... (10s elapsed)
aws_cloudformation_stack.network: Destruction complete

Destroy complete! Resources: 1 destroyed.

on_failure = "ROLLBACK"

$ terraform apply
aws_cloudformation_stack.network: Creating...
  name:          "" => "tf-networking-stack"
  on_failure:    "" => "ROLLBACK"
  outputs.%:     "" => "<computed>"
  parameters.%:  "" => "<computed>"
  policy_body:   "" => "<computed>"
  template_body: "" => "{\"Resources\":{\"myvpc\":{\"Properties\":{\"CidrBlock\":\"256.0.0.0/16\",\"Tags\":[{\"Key\":\"Name\",\"Value\":\"Primary_CF_VPC\"}]},\"Type\":\"AWS::EC2::VPC\"}}}"
aws_cloudformation_stack.network: Still creating... (10s elapsed)
aws_cloudformation_stack.network: Still creating... (20s elapsed)
aws_cloudformation_stack.network: Still creating... (30s elapsed)
Error applying plan:

1 error(s) occurred:

* aws_cloudformation_stack.network: ROLLBACK_COMPLETE: ["The following resource(s) failed to create: [myvpc]. . Rollback requested by user." "Value (256.0.0.0/16) for parameter cidrBlock is invalid. This is not a valid CIDR block."]

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
$ terraform destroy
Do you really want to destroy?
  Terraform will delete all your managed infrastructure.
  There is no undo. Only 'yes' will be accepted to confirm.

  Enter a value: yes

aws_cloudformation_stack.network: Refreshing state... (ID: arn:aws:cloudformation:us-west-2:112336751141:stack/tf-networking-stack/d1215080-6dd2-11e6-934e-51a68a2012f2)
aws_cloudformation_stack.network: Destroying...
aws_cloudformation_stack.network: Destruction complete

Destroy complete! Resources: 1 destroyed.

on_failure = "DELETE"

$ terraform apply
aws_cloudformation_stack.network: Creating...
  name:          "" => "tf-networking-stack"
  on_failure:    "" => "DELETE"
  outputs.%:     "" => "<computed>"
  parameters.%:  "" => "<computed>"
  policy_body:   "" => "<computed>"
  template_body: "" => "{\"Resources\":{\"myvpc\":{\"Properties\":{\"CidrBlock\":\"256.0.0.0/16\",\"Tags\":[{\"Key\":\"Name\",\"Value\":\"Primary_CF_VPC\"}]},\"Type\":\"AWS::EC2::VPC\"}}}"
aws_cloudformation_stack.network: Still creating... (10s elapsed)
aws_cloudformation_stack.network: Still creating... (20s elapsed)
aws_cloudformation_stack.network: Still creating... (30s elapsed)
Error applying plan:

1 error(s) occurred:

* aws_cloudformation_stack.network: DELETE_COMPLETE: ["The following resource(s) failed to create: [myvpc]. . Delete requested by user." "Value (256.0.0.0/16) for parameter cidrBlock is invalid. This is not a valid CIDR block."]

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
$ terraform show


$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment