Parameters for customization in AWS - Time & Space Complexity
When using parameters to customize AWS resources, it is important to understand how the time to apply these parameters changes as you add more.
We want to know how the number of parameters affects the time it takes to configure or deploy resources.
Analyze the time complexity of setting parameters in a CloudFormation stack update.
aws cloudformation update-stack \
--stack-name MyStack \
--template-body file://template.yaml \
--parameters \
ParameterKey=InstanceType,ParameterValue=t2.micro \
ParameterKey=KeyName,ParameterValue=my-key \
ParameterKey=DBName,ParameterValue=mydb \
# ... more parameters ...
This sequence updates a CloudFormation stack by passing a list of parameters to customize the resources.
Each parameter is processed as part of the update operation.
- Primary operation: Passing each parameter key-value pair to the update-stack API call.
- How many times: Once per parameter in the list.
As you add more parameters, the number of key-value pairs sent grows directly with the number of parameters.
| Input Size (n) | Approx. Api Calls/Operations |
|---|---|
| 10 | 1 update call with 10 parameters |
| 100 | 1 update call with 100 parameters |
| 1000 | 1 update call with 1000 parameters |
Pattern observation: The number of parameters grows linearly, and each parameter adds a small amount of processing time within a single API call.
Time Complexity: O(n)
This means the time to process parameters grows in direct proportion to how many parameters you provide.
[X] Wrong: "Adding more parameters does not affect update time because it is a single API call."
[OK] Correct: Even though it is one API call, each parameter adds work to process and validate, so more parameters increase the time needed.
Understanding how parameters affect deployment time helps you design scalable and maintainable infrastructure templates.
"What if parameters were nested or referenced other parameters? How would that affect the time complexity?"