Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CloudFormation: Unresolved resource dependencies [Ec2Instance] in the Outputs block of the template

I am trying to create a EC2 instance using cloudFormation template. I have written below JSON for this and trying to upload json using option in CloudFormation "Upload a template to Amazon S3". But after uploading JSON I am getting error:

Template validation error: Unresolved resource dependencies [Ec2Instance] in the Outputs block of the template.

Please advice what I am going wrong here?

{
    "Description": "Create an EC2 instance running the latest amazon Linux AMI.",
    "Parameters": {
        "KeyPair": {
            "Description": "The EC2 key Pair to allow SSH access to the instance",
            "Type": "String"
        }
    },
    "Resources": {
        "EC2Instance": {
            "Properties": {
                "ImageId": "ami-9d23aeea",
                "InstanceType": "t2.micro",
                "KeyName": {
                    "Ref": "KeyPair"
                }
            },
            "Type": "AWS::EC2::Instance"
        }
    },
    "Outputs": {
        "InstanceId": {
            "Description": "The InstanceId of newly created EC2 instance",
            "Value": {
                "Ref": "Ec2Instance"
            }
        }
    },
    "AWSTemplateFormatVersion": "2010-09-09"
}
like image 204
vickey99 Avatar asked Sep 02 '25 15:09

vickey99


1 Answers

I think you just made a typo. EC2Instance in your resources list and Ec2Instance in your outputs.

like image 145
stijndepestel Avatar answered Sep 05 '25 12:09

stijndepestel