Related Articles

12 Comments

  1. 1

    Py

    Hi Onur,
    How do you reference the VPC Id of an existing VPC in the CloudFormation script when you create subnets, internet gateway, route tables?
    Thanks
    Dude

    Reply
    1. 1.1

      Onur SALK

      Hello,

      You can find sample templates about vpc here

      Reply
  2. 2

    Helene Andromeda

    Hi Onur. In my template I launch more than one instances. I would like that the IP addresses of all of them are in the Output. But there is no way to do this because defining the object more than once is not possible.

    E.g my Outputs section is :

    “Outputs” : {
    “InstanceId” : {
    “Value” : { “Ref” : “QAserver1” },
    “Description” : “QAserver1 InstanceID”
    }
    },

    But this returns the value of only one instance. There is no way to duplicate this block, or define InstanceId more than once .

    And I can’t pass many objects to “Ref” like that for example: “Value” : { “Ref” : “QAserver1”, “Ref” : “QAserver2” },

    Is it actually possible to do it?

    Reply
  3. 3

    Helene Andromeda

    Please ignore my previous comment! I only have another question now:

    In the outputs I want to return the InstanceType and the KeyName.

    Cannot find a way to reference it with Ref and Fn::GetAtt doesn’t suppport it .

    Is there a way?

    Thanks!

    Reply
  4. 4

    Helene Andromeda

    Hi again – it is fine, I don’t need it anymore 🙂 Thanks

    Reply
  5. 5

    Vinod Chandar VR

    I am creating a cloudformation template for users which will create instances and give an application end point and user name and password . I am able to achieve unique application end point with join function but I am not able to generate a dynamic username . Could any one help with the function that should be used to achieve different username on every new attempt

    Reply
    1. 5.1

      Onur SALK

      Hi Vinod,

      Can you share your template here? So someone maybe can help you.

      Reply
  6. 6

    Raj Man

    Hi,

    I am getting following error, while executing CF Json script to create instance:

    “Value of property SecurityGroupIds must be of type List of String”

    I am using the “List” type in Parameters for SecurityGroup and Subnet as follows:

    “SecurityGroupIdsParameter” : {
    “Description”: “Security Groups that can be used to access the EC2 instances”,
    “Type”: “List”,
    “Default” : “sg-a71379c3”,
    “ConstraintDescription”: “must be list of EC2 Security group ids”
    },
    “SubnetIdsParameter” : {
    “Description”: “SubnetIds that can be used to access the EC2 instances”,
    “Type”: “List”,
    “Default” : “subnet-65def800”,
    “ConstraintDescription”: “must be list of EC2 subnet ids”

    and calling it using REF in the Resource section:

    “EC2Instance” : {
    “Type” : “AWS::EC2::Instance”,
    “Properties” : {
    “SecurityGroupIds” : [{ “Ref” : “SecurityGroupIdsParameter” }],
    “InstanceType” : { “Ref” : “InstanceTypeParameter” },
    “ImageId” : { “Ref” : “AMIImageIdParameter” },
    “KeyName” : { “Ref” : “KeyNameParameter” },
    “SubnetId” : { “Ref” : “SubnetIdsParameter” }
    }
    },

    It is giving error when “List” type is used and expects String type for both SecurityGroupID and Subnet Id. I want to give the choice of listing all SG’s and Subnets for making selection, instead of hardcoding specific subnet and SG.

    Any tips?

    thanks

    Reply
    1. 6.1

      Onur SALK

      Hi,

      You can try to use as { “Ref” : “SecurityGroupIdsParameter” } rather than [{ “Ref” : “SecurityGroupIdsParameter” }]

      Reply
      1. 6.1.1

        Raj Man

        Yes, i tried using without square brackets first and it was not working and then i added square brackets. Even then it was not working.

        Reply
  7. 7

    Raj Man

    Neither options work. Any other suggestions?

    Reply
    1. 7.1

      Onur SALK

      You can share your json with me or another way is get a developer support on AWS Developer forum.

      Reply

Leave a Reply to Raj Man Cancel reply