AWS DevOps DevOps Automation Tools & Scripting Techniques 5 — Questions and Answers
Question 1: A DevOps engineer wants to validate a CloudFormation template for syntax errors before deploying it. Which AWS CLI command performs this check?
- aws cloudformation describe-template --template-body file://template.yml
- aws cloudformation validate-template --template-body file://template.yml (Correct answer)
- aws cloudformation lint --template-body file://template.yml
- aws cloudformation test --template-body file://template.yml
Correct answer: aws cloudformation validate-template --template-body file://template.yml
aws cloudformation validate-template checks the template for JSON/YAML syntax errors and CloudFormation-specific structural issues without deploying resources.
Question 2: In AWS Step Functions, which state type is used to pause execution for a specific duration or until a specific timestamp before continuing?
- Wait state (Correct answer)
- Pass state
- Task state with heartbeat
- Choice state with time condition
Correct answer: Wait state
The Wait state suspends workflow execution for a specified number of seconds or until an absolute timestamp without consuming compute resources during the pause.
Question 3: A team wants to enforce coding standards in their Python Lambda functions by running flake8 as part of the CI pipeline. Where in a CodeBuild buildspec.yml should this linting step run?
- install phase
- pre_build phase (Correct answer)
- build phase
- post_build phase
Correct answer: pre_build phase
Linting in pre_build runs code quality checks before the main build process, allowing the build to fail fast if code standards are not met.
Question 4: A CloudFormation StackSet is used to deploy resources across 10 AWS accounts. The team wants at most 3 accounts to be updated simultaneously. Which parameter controls this?
- --max-concurrent-accounts 3
- --max-concurrent-percentage 30
- --operation-preferences MaxConcurrentCount=3 (Correct answer)
- --account-limit 3
Correct answer: --operation-preferences MaxConcurrentCount=3
--operation-preferences with MaxConcurrentCount=3 limits StackSet deployment parallelism so only 3 accounts are updated at any given time.
Question 5: Which technique allows an AWS CodeDeploy blue/green deployment to automatically shift 10% of traffic to the new version, monitor for 10 minutes, then shift the remaining 90%?
- Use a CodeDeploy deployment configuration with a Linear10PercentEvery10Minutes predefined configuration (Correct answer)
- Configure two separate target groups with weighted routing in Route 53
- Set TrafficShiftingConfig in the Lambda function alias
- Use CloudWatch alarms to manually trigger traffic shifting
Correct answer: Use a CodeDeploy deployment configuration with a Linear10PercentEvery10Minutes predefined configuration
CodeDeploy's Linear10PercentEvery10Minutes predefined deployment configuration incrementally shifts traffic in 10% blocks every 10 minutes for controlled rollouts.
Question 6: A developer uses jq in a bash script to extract the InstanceId from the JSON output of aws ec2 describe-instances. Which jq expression correctly extracts the first instance ID?
- .Reservations[0].Instances[0].InstanceId (Correct answer)
- .InstanceId
- .Reservations.Instances.InstanceId
- .[0].InstanceId
Correct answer: .Reservations[0].Instances[0].InstanceId
The EC2 describe-instances response nests instances under Reservations arrays, so the correct path traverses Reservations[0].Instances[0].InstanceId.
Question 7: When using AWS CDK, what is the purpose of the cdk.context.json file generated after running CDK commands?
- It stores CDK app environment variables for deployment
- It caches context lookups like VPC IDs and AMI IDs to avoid repeated API calls (Correct answer)
- It defines the CDK app's stack dependencies and deployment order
- It contains IAM permissions required by the CDK bootstrap role
Correct answer: It caches context lookups like VPC IDs and AMI IDs to avoid repeated API calls
cdk.context.json caches results of context lookups (VPC IDs, AZs, AMIs) so CDK does not make live AWS API calls on every synth, enabling reproducible builds.
A DevOps engineer wants to validate a CloudFormation template for syntax errors before deploying it.
Which AWS CLI command performs this check?