Skip to content

Cloudformation ImportValue

0
  1. I have a stack-set (infra-stack) which sets-up my infrastructure with EC2, RDS instances, this stack set does export the Instances Id
  2. Created an instance of the infra-stack and ensured that the instance Ids are available in the export lists / outputs
  3. I created another stack-set (alarms-stack) to create cloud-watch alarms for these instances - stack-set was created successfully
  4. Now when I run the create-stack-instance on the alarms-stack (in the same region and NOT cross-accounts), it fails without proper status/messages
  • The operation just fails and i don't see any reason in the aws console
  • I don't see any stack being created in the stacks list (though the stack-instances inside the stack-set does show a stack id!)
  • Using cli to describe the operation just gives the following (among other operation info)
  •         "Status": "FAILED",  "StatusReason": "User Initiated",
    

Would appreciate any assistance on this...

  • The second stack is using the exported value which is the instance id. The exported value will change if you re-run the first stack if it terminates the instances. Most likely it's failing for that reason. Instead of using exported values, save the value in SSM parameter, that should remove the error.

asked 2 years ago236 views

2 Answers
0

The issue you're experiencing with your CloudFormation stack instances failing to create without proper error messages is not uncommon and can be frustrating to troubleshoot. Here are some potential reasons and solutions for your situation:

  1. Permission Issues: When CloudFormation assumes the credentials of the user or service role to make API calls, it might not have the necessary permissions to create, delete, or update resources. This can result in failures without clear error messages. Ensure that the IAM role or user executing the stack has the required permissions for all resources being created in the alarms-stack.

  2. Export Value Availability: There might be a timing issue with the exported values from your infra-stack. Make sure that the exports are available before trying to create instances of the alarms-stack. You may need to add dependencies or adjust the order of operations.

  3. Stack Set Limitations: There could be issues related to stack set operations, such as exceeding service quotas or regional limitations. Check your AWS account's service quotas and ensure you're not hitting any limits.

  4. Template Size: If you've made changes to your template, ensure it doesn't exceed the maximum allowed size for a CloudFormation template body (51,200 bytes). Exceeding this limit can cause failures without clear error messages.

  5. Resource States: The EC2 or RDS instances you're referencing might not be in the correct state when the alarms-stack tries to create the CloudWatch alarms. Consider adding appropriate dependencies or wait conditions in your template.

To troubleshoot further:

  1. Use the AWS CLI to get more detailed error information. Try using the 'describe-stack-set-operation' command with the --operation-id parameter to get more details about the failed operation.

  2. Check the CloudTrail logs for any API calls that might have failed during the stack creation process.

  3. Consider breaking down your alarms-stack into smaller, more manageable pieces to isolate the issue.

  4. Temporarily simplify your alarms-stack template, removing some resources to see if you can identify which specific resource or section is causing the problem.

  5. If the problem persists and you can't identify the cause, you may need to contact AWS Support for further assistance. They can provide more detailed insights into the failure reasons that might not be visible through the console or CLI.

Remember, when troubleshooting CloudFormation issues, it's often helpful to start with a minimal template and gradually add complexity while testing at each step to pinpoint where the problem occurs.
Sources
Troubleshoot missing permission errors in CloudFormation | AWS re:Post
Stack status of UPDATE_ROLLBACK_COMPLETE but unable to update stack | AWS re:Post

answered 2 years ago

    • Ensured that the Permissions was not an issue by running the IAM Policy Simulator for both AWSCloudFormationStackSetAdministrationRole and AWSCloudFormationStackSetExecutionRoles

    • Export Values are available in the Cloud formation console and also listed using the cli command list-exports

    • Resources from infra-stack was created about a day earlier and are indeed available

    • Template Size - my template size is small and size should have mattered while creating the stack-set and not while creating the instance - correct?

    • Stack-set Limitation - i;m well under limit and have not exceeded any quotas as i'm still able to run/create other stacks without issues.

    • CLI describe-stack-set-operation didn't give much information other than the "User Initiated" as the reason!

    • haven't checked the cloudtrail logs - will check shortly.

0

You've mentioned that you are able to see the StackId in the StackInstances list. You can view the stack events of this stack, by following the below steps:

  1. Go to AWS CloudFormation console.
  2. Click on Stacks from the navigation pane on the left side. You should see a Filter status drop-down with a value of Active as shown in the screenshot.
  3. Select Deleted from this drop-down and then find the stack displayed in the StackInstances list of the StackSet.

Enter image description here

The most probable root cause here is that the Export name mentioned in the second StackSet (alarms-stack) is not correct. In such scenarios, we do not see any clear reason of failure in the StackSet. Requesting you to please visit the stack events of the failed StackInstance and check what's the error in there.

If you can't see any specific reason in the Stack events page as well, then I request you to reach out to AWS Support as further troubleshooting will require checking the stack details from our internal tools. If there's any new information you have found feel free to share it here.

AWS
SUPPORT ENGINEER

answered 2 years ago

AWS
EXPERT

reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.