Since Predictive Scaling requires more than 2 days worth of data to make predictions for the following days, and we don’t have this data available, we will need to simulate such an environment.
metric-preparation and navigate into this directory.mkdir metric-preparation && cd metric-preparation
curl -o prepare-metric-data.sh https://raw.githubusercontent.com/awslabs/ec2-spot-workshops/master/workshops/efficient-and-resilient-ec2-auto-scaling/prepare-metric-data.sh

nano prepare-metric-data.sh
Edit the time variable to:
time=$(date -d "$((5*i)) minutes ago")

curl -o metric-cpu.json https://raw.githubusercontent.com/awslabs/ec2-spot-workshops/master/workshops/efficient-and-resilient-ec2-auto-scaling/metric-cpu.json

curl -o metric-instances.json https://raw.githubusercontent.com/awslabs/ec2-spot-workshops/master/workshops/efficient-and-resilient-ec2-auto-scaling/metric-instances.json

bash prepare-metric-data.sh metric-cpu.json FCAJ-ASG && cat metric-cpu.json

bash prepare-metric-data.sh metric-instances.json FCAJ-ASG && cat metric-instances.json

The parameter FCAJ-ASG that appears in the two commands above is the name of the Auto Scaling Group that we will create later. Therefore, you need to create an ASG with the same name afterward, or you should change it to a different name now.
In Amazon Linux 2023, if you are using the correct AMI, AWS CLI is pre-installed. At this point, you only need to configure the credentials. Remember that you must have an IAM User with sufficient permissions to upload data to CloudWatch or at least enough to complete this workshop.
aws configure

aws cloudwatch put-metric-data --namespace 'FCAJ Custom Metrics' --metric-data file://metric-cpu.json
aws cloudwatch put-metric-data --namespace 'FCAJ Custom Metrics' --metric-data file://metric-instances.json

CloudWatch



We will have to wait about 30 minutes or longer for CloudWatch to process the data. Instead of waiting, we can proceed with the next sections.