Wednesday, May 24, 2017

"ResourceStatusReason": "No export named [x] found. Rollback requested by user.",

Was having someone help me test FireboxCloud automation script and got this error.

"ResourceStatusReason": "No export named [x] found. Rollback requested by user.",

What does this mean?

At the bottom of the templates that create the resources there are a list of outputs. For example in this template:

https://github.com/tradichel/FireboxCloudAutomation/blob/master/code/resources/firebox-nat/subnets.yaml

There are outputs at the bottom that look like this:

Outputs:
  FireboxPrivateSubnet:
    Value: !Ref FireboxPrivateSubnet
    Export:
      Name: "FireboxPrivateSubnet"
  FireboxPublicSubnet:
    Value: !Ref FireboxPublicSubnet
    Export:
      Name: "FireboxPublicSubnet"
  FireboxPublicRouteTable:
    Value: !Ref FireboxPublicRouteTable
    Export:
      Name: "FireboxPublicRouteTable"
  FireboxPrivateRouteTable:
    Value: !Ref FireboxPrivateRouteTable
    Export:
      Name: "FireboxPrivateRouteTable"
  FireboxPublicNacl:
    Value: !Ref FireboxPublicSubnetNacl
    Export:
      Name: "FireboxPublicNacl"

There is some fairly new (and awesome) functionality in CloudFormation that allows you to easily import the output of one template into another using ImportValue.

When I create my FireboxCloud I want to put the ENIs (one public and one private) into their respective subnets. I can reference the subnets using !ImportValue as shown below:

Resources:
  FireboxPublicNetworkInterface:
    Type: "AWS::EC2::NetworkInterface"
    Properties:
      Description: Firebox Public Network Interface
      GroupSet:
        - !ImportValue FireboxPublicSecurityGroup
      SubnetId: !ImportValue FireboxPublicSubnet
      SourceDestCheck: false

When the person helping me ran my scripts they got this error:

"ResourceStatusReason": "No export named [x] found. Rollback requested by user.",

It's a little odd that I was not also getting this error. Typically this error is caused when the ImportValue has a typo in the name of the OutputValue it is referencing.

What was odd in this case: I wasn't getting the error. That's because I had added a resource after the fact that reference the output value of a CloudFormation stack I had already created. This seems like it shouldn't be possible and is not correct. If referencing the value in the template itself I should have referenced the name of the resource created in the same template using Ref.

The subsequent problem was that I could not delete the CloudFormation stack because it said the stack was creating an output that was referenced by something else (itself!). I got around this by updating the stack and removing the incorrect ImportValue to a resource in the stack and replacing it with Ref. After that was fixed I could delete the stack.