Configuring EC2 instance profiles
In the EC2 Auto Scaling launch configuration you defined in the previous example, you referenced an IAM instance profile, which we need to create as a separate resource in our stack. EC2 instance profiles allow you to attach an IAM role, which your EC2 instances can use to gain access to AWS resources and services, and in the ECS container instance use case. Recall from Chapter 4, when you created your first ECS cluster, that an IAM instance profile and associated IAM role that granted various ECS permissions was automatically attached to your ECS container instance.
Because we are configuring our ECS cluster and Auto Scaling group from scratch, we need to explicitly define an appropriate IAM instance profile and linked IAM role, as demonstrated in the following example:
Resources: ... ... ApplicationAutoscalingInstanceProfile: Type: AWS::IAM::InstanceProfile Properties: Roles: - Ref: ApplicationAutoscalingInstanceRole ApplicationAutoscalingInstanceRole...