0

I'm creating a SpotFleet request using CloudFormation, but whenever I try to deploy it, fails with the message:

Unable to fetch parameters [ami-09bee01cc997a78a6] from parameter store for this account.

I'm using the following code (snippet):

SpotFleet:
    Type: AWS::EC2::SpotFleet
    Properties:
      SpotFleetRequestConfigData:
        ExcessCapacityTerminationPolicy: default
        InstanceInterruptionBehavior: terminate
        IamFleetRole: !GetAtt SpotFleetRole.Arn
        TargetCapacity: !Ref ClusterSize
        TerminateInstancesWithExpiration: false
        LaunchSpecifications:
          - IamInstanceProfile:
              Arn: !Ref ECSInstanceProfile
            ImageId: !Ref LatestAmiId
            InstanceType: !Ref SpotFleetInstanceType
            KeyName: !Ref KeyName
            Monitoring:
              Enabled: false
            SecurityGroups:
              - GroupId: !Ref ECSHostSecurityGroup
            SubnetId:  !Ref PublicSubnet
            ...

The ImageId is:

  LatestAmiId:
    Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
    Default: '/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id'

When I manually fetch the image id from the AWS CLI I get:

aws ssm get-parameters --names /aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id --region us-east-1 --output json | jq -r ."Parameters[].Value"

Output:

ami-09bee01cc997a78a6

If a manually hardcode this value into the ImageId parameter, it returns the same error (Unable to fetch parameters...)

Why it is failing if I am able to fetch the id value from the CLI?

Edenshaw
  • 1,692
  • 18
  • 27
  • 2
    Have you tried any of the possible solutions listed [here](https://stackoverflow.com/questions/51918238/unable-to-fetch-paramters-param-value-from-parameter-store-for-this-account)? – Marcin Nov 09 '20 at 23:50

1 Answers1

0

Thanks to @Marcin's comment and this answer, I found the problem.

The problem is that I was using the wrong parameter type for the Image Id. I was using:

  LatestAmiId:
    Type: AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>
    Default: '/aws/service/ecs/optimized-ami/amazon-linux-2/recommended/image_id'

and I should be using this:

  LatestAmiId:
    Description: Linux AMI
    Type: AWS::EC2::Image::Id
Edenshaw
  • 1,692
  • 18
  • 27