Cloudformation script fails with message SpotFleetRequestConfigData/LaunchSpecifications/0/IamInstanceProfile: expected type: JSONObject, found: String

0

I am trying to launch a spot fleet request via a clouldformation yaml. During this process, I keep getting an error "#/SpotFleetRequestConfigData/LaunchSpecifications/0/IamInstanceProfile: expected type: JSONObject, found: String"

For some reason, I am unable to pass the role to the spot instance getting created. the script works fine without this particular line. the failiing line is the first one in LaunchSpecifications. i tried to pipe in the raw json too, but that gives the same error. My guess is this is just a bad error message. How do i resolve this? Is there a way to check if this is a permissions issue? Also, this config works with launching a plain old ec2 instance. Just fails in the case of a SpotFleet request.


AWSTemplateFormatVersion: 2010-09-09
Description: >-
  AWS CloudFormation template for launching a spot ec2-instance 

Resources:
  SpotInstance:
    Type: "AWS::EC2::SpotFleet"
    Properties:
      SpotFleetRequestConfigData:
        IamFleetRole: arn:aws:iam::773057xxxxxx:role/aws-ec2-spot-fleet-tagging-role
        TargetCapacity: 1
        LaunchSpecifications:
        - IamInstanceProfile: arn:aws:iam::773057xxxxxx:instance-profile/EC2_Role_R53
          KeyName: xxxxxxxxxxxxxx
          NetworkInterfaces:
            - AssociatePublicIpAddress: true
              DeleteOnTermination: true
              DeviceIndex: '0'
              SubnetId: subnet-e18921ca
              Groups:
                - sg-cfa4c3ab
                - sg-01d9bd3d67ed8a312
          ImageId: ami-0574da719dca65348 #generic ubuntu ami 22.04
          InstanceType: t2.medium
1 Antwort
1
Akzeptierte Antwort

Would it work if you modify it as follows?

Before

LaunchSpecifications:
    - IamInstanceProfile: arn:aws:iam::773057xxxxxx:instance-profile/EC2_Role_R53

After

LaunchSpecifications:
    - IamInstanceProfile: 
         Arn: arn:aws:iam::773057xxxxxx:instance-profile/EC2_Role_R53

Check out the following document! https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-spotfleet-iaminstanceprofilespecification.html

imiky
beantwortet vor einem Jahr
EXPERTE
überprüft vor einem Jahr

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen