Compare licence models, rightsize on paper, and build two identical environments from one template
Task
Read how AWS bills a Windows Server image (license-included) against an Amazon Linux image, and compare instance sizes to rightsize an invented server whose metrics show it is mostly idle. Then record that environment's settings in an AWS CloudFormation template and build it twice, as dev and test, so both come out exactly the same. Finally, apply the rightsizing decision by changing one line of the template and updating both environments the same way. You finish able to explain license-included against BYOL, why rightsizing comes before any commitment, and what infrastructure as code changes and does not change.
Steps
- See license-included pricing in the image itself. Look up the latest Windows Server 2022 and Amazon Linux 2023 images through their public parameters, and read how each is billed:
WIN=$(aws ssm get-parameter --name /aws/service/ami-windows-latest/Windows_Server-2022-English-Full-Base --query 'Parameter.Value' --output text)
LNX=$(aws ssm get-parameter --name /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64 --query 'Parameter.Value' --output text)
aws ec2 describe-images --image-ids "$WIN" "$LNX" --query 'Images[].[Name,PlatformDetails,UsageOperation]' --output table
The Windows image reads Windows with a usage operation of RunInstances:0002: the Windows Server licence is part of the instance price. The Linux image reads Linux/UNIX and RunInstances, with no licence charge. A company that already owns per-core Windows licences and wanted to bring them (BYOL) would need Amazon EC2 Dedicated Hosts instead; that is lesson 23's subject, and this lab creates none. 2. Rightsize an invented server. It was moved to AWS at the same size it had on premises, a t3.small. Over three months its CPU averaged 4 percent and peaked at 11 percent, and its memory never passed 600 MiB. Compare the sizes:
aws ec2 describe-instance-types --instance-types t3.micro t3.small --query 'InstanceTypes[].[InstanceType,VCpuInfo.DefaultVCpus,MemoryInfo.SizeInMiB]' --output table
A t3.micro has the same two vCPUs and 1024 MiB of memory, enough for this workload with room to spare. Rightsizing it now, before buying any Savings Plan or Reserved Instance, avoids locking in spending on capacity it does not use. 3. Write a template that records the environment's settings. It still holds the old size, t3.small:
cat > clf-lab05-template.yaml << 'EOF'
AWSTemplateFormatVersion: '2010-09-09'
Description: clf-lab05 - the same settings for every environment
Parameters:
EnvName:
Type: String
AllowedValues: [dev, test]
Resources:
SizeParameter:
Type: AWS::SSM::Parameter
Properties:
Name: !Sub '/clf-lab05/${EnvName}/instance-type'
Type: String
Value: t3.small
LicenceParameter:
Type: AWS::SSM::Parameter
Properties:
Name: !Sub '/clf-lab05/${EnvName}/licence-model'
Type: String
Value: license-included
EOF
- Build both environments from the same file. Each
deploywaits until its stack is complete:
aws cloudformation deploy --stack-name clf-lab05-dev --template-file clf-lab05-template.yaml --parameter-overrides EnvName=dev
aws cloudformation deploy --stack-name clf-lab05-test --template-file clf-lab05-template.yaml --parameter-overrides EnvName=test
- Read both environments back and compare them:
aws ssm get-parameters-by-path --path /clf-lab05 --recursive --query 'Parameters[].[Name,Value]' --output table
Four parameters, and dev and test agree line for line. No two hand-built environments are guaranteed to do that. 6. Apply the rightsizing decision as a change to the template, then update both environments:
sed -i 's/Value: t3.small/Value: t3.micro/' clf-lab05-template.yaml
aws cloudformation deploy --stack-name clf-lab05-dev --template-file clf-lab05-template.yaml --parameter-overrides EnvName=dev
aws cloudformation deploy --stack-name clf-lab05-test --template-file clf-lab05-template.yaml --parameter-overrides EnvName=test
Notice what automation did and did not do. It made the change identical in both places and left a text file you could review. It did not lower the price of anything, and it did not make anyone other than you responsible for these resources.
Verify
aws ssm get-parameters-by-path --path /clf-lab05 --recursive --query 'length(Parameters)' --output text
Expected output: 4.
aws ssm get-parameters-by-path --path /clf-lab05 --recursive --query "length(Parameters[?Value=='t3.micro'])" --output text
Expected output: 2, the rightsized value in both environments.
WIN=$(aws ssm get-parameter --name /aws/service/ami-windows-latest/Windows_Server-2022-English-Full-Base --query 'Parameter.Value' --output text)
aws ec2 describe-images --image-ids "$WIN" --query 'Images[0].UsageOperation' --output text
Expected output: RunInstances:0002, the license-included Windows billing code.
Cost and clean-up
CloudFormation does not charge for stacks of resources like these, and Parameter Store standard parameters carry no storage charge; the Systems Manager pricing page has the current terms. Reading images and instance types costs nothing.
Created by this lab: the CloudFormation stack clf-lab05-dev and its two parameters under /clf-lab05/dev; the CloudFormation stack clf-lab05-test and its two parameters under /clf-lab05/test; the file clf-lab05-template.yaml in your CloudShell home directory.
- Delete both stacks, which deletes their parameters, and wait until they are gone:
aws cloudformation delete-stack --stack-name clf-lab05-dev
aws cloudformation delete-stack --stack-name clf-lab05-test
aws cloudformation wait stack-delete-complete --stack-name clf-lab05-dev
aws cloudformation wait stack-delete-complete --stack-name clf-lab05-test
- Remove the template:
rm clf-lab05-template.yaml
Check it is gone
aws ssm get-parameters-by-path --path /clf-lab05 --recursive --query 'length(Parameters)' --output text
aws cloudformation list-stacks --stack-status-filter CREATE_COMPLETE UPDATE_COMPLETE DELETE_FAILED --query "length(StackSummaries[?starts_with(StackName, 'clf-lab05-')])" --output text
Expected output: 0 from each command.
Notes
The RunInstances:0002 code is how AWS's billing records mark Windows with the licence included. AWS License Manager would help a company that uses BYOL track licence use across accounts; it is not needed for license-included images, because AWS supplies the licence.
The memory figure in step 2 is invented. In a real account, CPU utilisation comes from Amazon CloudWatch by default, while memory needs the CloudWatch agent on the instance. AWS Compute Optimizer and AWS Cost Explorer can also suggest a size.
This is an independent study companion for the AWS Certified Cloud Practitioner (CLF-C02) exam and is not produced by or endorsed by Amazon Web Services. AWS, Amazon Web Services and AWS Certified Cloud Practitioner are trademarks of Amazon.com, Inc. or its affiliates.
This is an independent study companion for AWS Certified Cloud Practitioner CLF-C02 and is not produced by or endorsed by CompTIA.