Home > Back-end >  Cloudformation init - install multiple packages
Cloudformation init - install multiple packages

Time:11-28

I have the following parameter that asks the user what packages are to be installed:

  Packages:
    Description: A SPACE seperated list of packages that you want installed on this instance.
    Type: String
    Default: None

Then within my resource definition for EC2 instance, I have:

  WebServerHost:
    Type: AWS::EC2::Instance
    Metadata:
      Comment: Install HTTP server
      AWS::CloudFormation::Init:
        config:
          packages:
            yum:
              Fn::Join: [ ' ', [ !Ref Packages ] ]
      

But that doesn't work! Please can someone advise what I am doing wrong or if I am taking the wrong approach? Thanks

CodePudding user response:

Packages takes object, not a list. So you can't do that dynamically the way you want. You have to explicitly specify the correct values for yum, as in that case, they can't be passed to as Parameters.

The only way around that would be through CloudFormation macro, which you would have to develop and which would correctly setup yum property as object, not list.

  • Related