Cloud Automation and Scripting Lab
If a cloud operation must be performed repeatedly, consistently, and reliably, it is a strong candidate for automation.
Welcome to Lab 22 of the CompTIA Cloud+ practical lab sequence.
In the previous labs, you built and operated cloud environments through:
Provisioning βNetworking βStorage βIdentity βAvailability βBackup βDisaster Recovery βMonitoring βLogging βAlerting βCost OptimizationYou can now identify resources that:
-
require configuration
-
need monitoring
-
generate alerts
-
require backups
-
consume unnecessary cost
-
need operational maintenance
But manually performing every cloud operation creates another problem:
Engineer βManual Task βRepeat Task βRepeat Again βHuman Error βConfiguration DriftCloud environments therefore rely heavily on:
CLI+Scripts+APIs+Schedulers+Automation PlatformsIn this lab, you will automate common cloud operational tasks while learning how to build automation that is:
Repeatable
Controlled
Observable
Testable
Recoverable
Secureπ― Mission Information
Section titled βπ― Mission Informationβ| Item | Details |
|---|---|
| Lab | 22 β Cloud Automation and Scripting Lab |
| Difficulty | Intermediate |
| Estimated Time | 150β210 Minutes |
| Certification Alignment | CompTIA Cloud+ |
| Primary Focus | Cloud Operations Automation |
| Previous Lab | 21 β Cloud Cost Optimization Lab |
| Career Alignment | Cloud Administrator, Cloud Engineer, DevOps Engineer, Cloud Operations Engineer |
| Major Skills | CLI, Scripting, APIs, Scheduling, Validation, Error Handling, Idempotency |
| Deliverable | Cloud Automation Scripts + Test Report + Automation Runbook |
π’ Scenario
Section titled βπ’ ScenarioβYour organization operates:
Cloud Environment | +----------------+----------------+ | | | v v v Production Development Testing | | | v v v Compute Compute Compute Storage Storage Storage Network Network NetworkThe cloud operations team currently performs several repetitive tasks manually:
Start Development VMs
Stop Development VMs
Create Resources
Apply Tags
Check Resource State
Validate Configurations
Collect Resource Inventory
Remove Temporary ResourcesThis creates operational problems.
For example:
Engineer A βApplies Correct Tags
Engineer B βForgets CostCenter Tag
Engineer C βUses Different Naming ConventionThe result is:
Inconsistency+Human Error+Poor Governance+Operational OverheadYour mission is to automate selected cloud operations and build a safe automation workflow.
π― Lab Objectives
Section titled βπ― Lab ObjectivesβBy completing this lab, you should be able to:
-
explain cloud automation
-
identify automation candidates
-
understand cloud CLIs
-
understand scripting
-
understand cloud APIs
-
compare GUI, CLI, scripts, and APIs
-
authenticate CLI tools
-
query cloud resources
-
create resource inventory scripts
-
automate resource creation
-
automate start and stop operations
-
automate resource tagging
-
use loops
-
use variables
-
use conditional logic
-
understand functions
-
understand exit codes
-
validate command results
-
implement error handling
-
generate automation logs
-
understand scheduling
-
understand idempotency
-
understand configuration drift
-
safely handle credentials
-
understand least privilege for automation
-
test automation
-
understand dry-run concepts
-
create rollback plans
-
document automation workflows
-
build operational automation runbooks
01 β Understand Cloud Automation
Section titled β01 β Understand Cloud AutomationβCloud automation uses software to perform cloud operational tasks with limited manual intervention.
Instead of:
Engineer βOpen Portal βFind VM βClick Stopautomation can perform:
Schedule βScript βFind Development VMs βStop VMs βRecord Result02 β Why Cloud Automation Matters
Section titled β02 β Why Cloud Automation MattersβAutomation can improve:
Consistency
Speed
Repeatability
Scalability
Operational Efficiency
GovernanceIt can also reduce:
Manual Work
Human Error
Configuration Differences
Repetitive Administration03 β Automation Does Not Remove Risk
Section titled β03 β Automation Does Not Remove RiskβPoor automation can turn:
One Human Errorinto:
Automated Error βHundreds of ResourcesTherefore:
Automation increases both operational capability and operational responsibility.
04 β Identify Automation Candidates
Section titled β04 β Identify Automation CandidatesβGood candidates are often tasks that are:
Repetitive
Predictable
Rule-Based
Frequent
Time-Consuming
Prone to Manual ErrorExamples:
-
VM start/stop
-
backups
-
tagging
-
resource inventory
-
health checks
-
configuration validation
-
log collection
-
temporary environment cleanup
05 β Avoid Automating Poor Processes
Section titled β05 β Avoid Automating Poor ProcessesβDo not begin with:
Bad Manual Process βAutomate βFast Bad ProcessFirst:
Understand βStandardize βValidate βAutomate06 β Understand Automation Interfaces
Section titled β06 β Understand Automation InterfacesβCloud automation commonly uses:
Portal / GUI
CLI
SDK
API
Scripts
Infrastructure as Code
Automation Services07 β GUI vs CLI
Section titled β07 β GUI vs CLIβGUI:
Human βPortal βCloud APICLI:
Human / Script βCLI Command βCloud APIThe CLI makes operations easier to:
Repeat
Script
Document
Automate08 β Understand Cloud CLIs
Section titled β08 β Understand Cloud CLIsβMajor cloud platforms provide command-line interfaces.
Examples include:
AWS CLI
Azure CLI
Google Cloud CLIThe exact commands differ, but the operational principles remain similar.
09 β Verify Your CLI
Section titled β09 β Verify Your CLIβUse the CLI appropriate for your lab environment.
Example:
aws --versionor:
az versionor:
gcloud versionRecord:
CLI:
Version:
Environment:10 β Understand CLI Authentication
Section titled β10 β Understand CLI AuthenticationβBefore performing operations:
CLI βAuthentication βAuthorization βCloud APIYour automation identity must have appropriate permissions.
11 β Avoid Overprivileged Automation
Section titled β11 β Avoid Overprivileged AutomationβPoor design:
Automation Script βGlobal AdministratorBetter:
Automation Requirement βRequired Operations βMinimum Permissions βAutomation Identity12 β Validate Your Current Identity
Section titled β12 β Validate Your Current IdentityβDetermine which identity the CLI is using.
For AWS:
aws sts get-caller-identityFor Azure:
az account showFor Google Cloud:
gcloud auth listRecord:
Identity:
Account / Subscription / Project:
Permissions:13 β Perform Your First Resource Query
Section titled β13 β Perform Your First Resource QueryβInstead of manually browsing resources, query them.
AWS example:
aws ec2 describe-instancesAzure example:
az vm listGoogle Cloud example:
gcloud compute instances list14 β Request Structured Output
Section titled β14 β Request Structured OutputβAutomation works better with structured data.
Common formats include:
JSON
CSV
TSV
YAMLExample concept:
CLI βJSON βScript βProcessing15 β Build a Resource Inventory
Section titled β15 β Build a Resource InventoryβYour inventory should contain:
| Resource | Type | Region | State | Owner | Environment |
|---|---|---|---|---|---|
| Web-01 | VM | ||||
| App-01 | VM | ||||
| DB-01 | Database |
16 β Understand Variables
Section titled β16 β Understand VariablesβVariables allow reusable scripts.
Instead of:
echo "cloudplus-web-01"use:
RESOURCE_NAME="cloudplus-web-01"
echo "$RESOURCE_NAME"17 β Why Variables Matter
Section titled β17 β Why Variables MatterβWithout variables:
Same ValueRepeated EverywhereWith variables:
Value βVariable βReuseThis makes scripts easier to:
-
maintain
-
update
-
reuse
18 β Create Your First Script
Section titled β18 β Create Your First ScriptβCreate:
cloud-inventory.shExample:
#!/bin/bash
echo "Cloud Resource Inventory"echo "========================"
dateMake it executable where required:
chmod +x cloud-inventory.shRun:
./cloud-inventory.sh19 β Add a Cloud Query
Section titled β19 β Add a Cloud QueryβAWS example:
#!/bin/bash
echo "Cloud Resource Inventory"
aws ec2 describe-instancesAzure:
#!/bin/bash
echo "Cloud Resource Inventory"
az vm list --output tableGoogle Cloud:
#!/bin/bash
echo "Cloud Resource Inventory"
gcloud compute instances list20 β Understand Script Exit Codes
Section titled β20 β Understand Script Exit CodesβCommands normally return an exit status.
Conceptually:
0=Success
Non-Zero=ErrorCheck:
echo $?after a command on Linux shells.
21 β Validate Command Success
Section titled β21 β Validate Command SuccessβExample:
if command; then echo "Operation successful"else echo "Operation failed"fiAutomation should not assume:
Command Executed=Command Succeeded22 β Understand Conditional Logic
Section titled β22 β Understand Conditional LogicβConditional logic allows automation to make decisions.
Example:
IFVM Is Running
THENStop VM
ELSEDo Nothing23 β Basic Conditional Example
Section titled β23 β Basic Conditional ExampleβSTATUS="running"
if [ "$STATUS" = "running" ]; then echo "VM is running"else echo "VM is not running"fi24 β Understand Loops
Section titled β24 β Understand LoopsβSuppose you have:
VM1
VM2
VM3
VM4Instead of repeating commands manually, use:
FOR EACH VM βPerform Operation25 β Basic Loop Example
Section titled β25 β Basic Loop Exampleβfor vm in web01 web02 app01do echo "Checking $vm"done26 β Build a Resource Check Script
Section titled β26 β Build a Resource Check ScriptβConceptually:
Get Resources βFor Each Resource βCheck State βRecord Result27 β Automate VM Start Operations
Section titled β27 β Automate VM Start OperationsβYour development environment contains:
dev-web-01
dev-app-01Instead of manually starting them each morning:
Schedule βStart Script βDevelopment VMs βRunning28 β AWS Start Example
Section titled β28 β AWS Start Exampleβaws ec2 start-instances \ --instance-ids i-EXAMPLEUse your own authorized lab resource identifiers.
29 β Azure Start Example
Section titled β29 β Azure Start Exampleβaz vm start \ --resource-group cloudplus-lab \ --name dev-web-0130 β Google Cloud Start Example
Section titled β30 β Google Cloud Start Exampleβgcloud compute instances start dev-web-01 \ --zone=YOUR_ZONE31 β Verify Start Operation
Section titled β31 β Verify Start OperationβNever stop at:
Start Command SubmittedValidate:
Command βAPI βResource State βRunning32 β Automate VM Stop Operations
Section titled β32 β Automate VM Stop OperationsβAfter business hours:
Development VMs βStop Script βStopped βReduced Runtime CostThis connects directly with:
Lab 21 β Cloud Cost Optimization Lab
33 β AWS Stop Example
Section titled β33 β AWS Stop Exampleβaws ec2 stop-instances \ --instance-ids i-EXAMPLE34 β Azure Stop Example
Section titled β34 β Azure Stop Exampleβaz vm deallocate \ --resource-group cloudplus-lab \ --name dev-web-0135 β Google Cloud Stop Example
Section titled β35 β Google Cloud Stop Exampleβgcloud compute instances stop dev-web-01 \ --zone=YOUR_ZONE36 β Understand Stop vs Delete
Section titled β36 β Understand Stop vs DeleteβBe careful:
STOPβ DELETEStop generally preserves the resource.
Delete removes it.
Automation must make this distinction explicit.
37 β Build a Safe Stop Script
Section titled β37 β Build a Safe Stop ScriptβConceptually:
Find Resources βEnvironment = Development? βYES βStopNever use:
Find All VMs βStop Everythingwithout appropriate safeguards.
38 β Use Tags as Automation Controls
Section titled β38 β Use Tags as Automation ControlsβExample:
Environment = Development
AutoShutdown = TrueThen:
Script βFind AutoShutdown=True βStop Only Those Resources39 β Why Tag-Driven Automation Helps
Section titled β39 β Why Tag-Driven Automation HelpsβTags provide:
Selection
Ownership
Intent
Governanceinstead of hardcoding every resource.
40 β Build the Automation Tagging Standard
Section titled β40 β Build the Automation Tagging StandardβExample:
| Tag | Example |
|---|---|
| Environment | Development |
| Owner | CloudTeam |
| AutoShutdown | True |
| CostCenter | IT |
| ManagedBy | Automation |
41 β Automate Missing Tag Detection
Section titled β41 β Automate Missing Tag DetectionβConceptually:
All Resources βCheck Required Tags βMissing? / \ YES NO β βReport Pass42 β Create a Tag Compliance Report
Section titled β42 β Create a Tag Compliance Reportβ| Resource | Environment | Owner | CostCenter | Status |
|---|---|---|---|---|
| VM-01 | Dev | Cloud | IT | Pass |
| VM-02 | Cloud | Fail |
43 β Automate Tagging Carefully
Section titled β43 β Automate Tagging CarefullyβDo not automatically overwrite:
Existing Owner
Existing CostCenter
Business Metadatawithout defined governance.
Prefer:
Check βMissing? βApply Approved Defaultwhere appropriate.
44 β Understand APIs
Section titled β44 β Understand APIsβAn API allows software to interact programmatically with cloud services.
Conceptually:
Script βAPI Request βCloud Service βAPI Response45 β Understand HTTP Methods
Section titled β45 β Understand HTTP MethodsβCommon API methods include:
GETPOSTPUTPATCHDELETEAt a high level:
GET=Retrieve
POST=Create / Submit
PUT/PATCH=Update
DELETE=RemoveExact behavior depends on the API.
46 β Understand API Requests
Section titled β46 β Understand API RequestsβAn API request may contain:
Endpoint
Authentication
Method
Headers
Parameters
Body47 β Understand API Responses
Section titled β47 β Understand API ResponsesβResponses may include:
Status Code
Headers
Data
Error Message48 β Understand Common HTTP Status Codes
Section titled β48 β Understand Common HTTP Status CodesβExamples:
200Success
201Created
400Bad Request
401Unauthenticated
403Forbidden
404Not Found
429Too Many Requests
500Server Error49 β Understand Authentication vs Authorization Errors
Section titled β49 β Understand Authentication vs Authorization Errorsβ401generally means an authentication problem.
403generally means:
Identity Known βPermission Denied50 β Understand API Rate Limits
Section titled β50 β Understand API Rate LimitsβCloud APIs may restrict request frequency.
Poor automation:
10,000 RequestsInstantlymay result in:
Throttling51 β Handle API Throttling
Section titled β51 β Handle API ThrottlingβAutomation should consider:
Retry
Delay
Backoff
Rate Limits52 β Understand Retry Logic
Section titled β52 β Understand Retry LogicβPoor:
Request Failed βScript Stops ForeverBetter:
Request Failed βRetry Appropriate? / \ YES NO β βWait Fail βRetry53 β Avoid Infinite Retry
Section titled β53 β Avoid Infinite RetryβDo not create:
Failure βRetry βFailure βRetry βForeverUse:
Maximum Attempts+Timeout+Logging54 β Understand Exponential Backoff
Section titled β54 β Understand Exponential BackoffβConceptually:
Retry 1Wait 1 Second
Retry 2Wait 2 Seconds
Retry 3Wait 4 Seconds
Retry 4Wait 8 SecondsThis can help when dealing with temporary API throttling or service issues.
55 β Understand Error Handling
Section titled β55 β Understand Error HandlingβAutomation should anticipate:
Authentication Failure
Permission Failure
Resource Missing
Network Failure
Invalid Input
API Failure
Timeout
Dependency Failure56 β Build Error Handling into Scripts
Section titled β56 β Build Error Handling into ScriptsβExample:
if ! command; then echo "ERROR: operation failed" exit 1fi57 β Produce Meaningful Errors
Section titled β57 β Produce Meaningful ErrorsβPoor:
ERRORBetter:
ERROR:Failed to stop dev-web-01
Time:18:05
Operation:Stop VM58 β Understand Automation Logging
Section titled β58 β Understand Automation LoggingβYour automation should create its own operational record.
Example:
2026-08-25 18:00STARTShutdown automation
2026-08-25 18:01SUCCESSdev-web-01 stopped
2026-08-25 18:02SUCCESSdev-app-01 stopped
2026-08-25 18:03COMPLETE59 β Build a Simple Script Logger
Section titled β59 β Build a Simple Script LoggerβExample:
log() { echo "$(date '+%Y-%m-%d %H:%M:%S') $1"}Then:
log "Starting cloud automation"60 β Why Automation Logs Matter
Section titled β60 β Why Automation Logs MatterβThey help answer:
Did the script run?
When?
What did it change?
Which resource failed?
What was the result?61 β Correlate Automation with Audit Logs
Section titled β61 β Correlate Automation with Audit LogsβRemember Lab 19.
Your script may log:
18:01Stopped dev-web-01while the cloud audit trail records:
18:01StopInstance API CallAutomationIdentityTogether they provide stronger operational evidence.
62 β Understand Scheduling
Section titled β62 β Understand SchedulingβAutomation can run based on:
Time
Event
Condition
Request63 β Time-Based Automation
Section titled β63 β Time-Based AutomationβExample:
08:00Start Development
18:00Stop Development64 β Event-Based Automation
Section titled β64 β Event-Based AutomationβExample:
New Resource Created βAutomation βCheck Required Tags65 β Condition-Based Automation
Section titled β65 β Condition-Based AutomationβExample:
CPU > Threshold βAlert βAutomation βScale ResourceAutomated remediation requires careful safeguards.
66 β Understand Scheduled Tasks
Section titled β66 β Understand Scheduled TasksβOn Linux, scheduled jobs may use:
cronExample concept:
0 18 * * 1-5meaning:
18:00MondayβFriday67 β Understand Cloud-Native Scheduling
Section titled β67 β Understand Cloud-Native SchedulingβCloud platforms also provide managed scheduling and automation services.
Conceptually:
Cloud Scheduler βTrigger βFunction / Script / Workflow βCloud API68 β Build the Development Shutdown Workflow
Section titled β68 β Build the Development Shutdown Workflowβ18:00 βScheduler βAutomation Script βFind Resources:AutoShutdown=True βValidate Environment βStop Resource βVerify State βWrite Log69 β Build the Development Startup Workflow
Section titled β69 β Build the Development Startup Workflowβ08:00 βScheduler βFind Approved Resources βStart βWait βValidate βWrite Log70 β Understand Idempotency
Section titled β70 β Understand IdempotencyβIdempotency is a critical automation concept.
An idempotent operation can be run repeatedly without creating unintended additional changes.
Example:
Desired State:VM StoppedIf VM is already stopped:
Run Script βNo Unnecessary Change71 β Non-Idempotent Example
Section titled β71 β Non-Idempotent ExampleβImagine:
Run Script βCreate VM
Run Again βCreate Another VM
Run Again βCreate Another VMwhen only one VM was required.
That is dangerous automation behavior.
72 β Build Idempotent Logic
Section titled β72 β Build Idempotent LogicβInstead:
Does VM Exist? / \ YES NO β βValidate Create73 β Understand Desired State
Section titled β73 β Understand Desired StateβA strong automation model focuses on:
Current State βCompare βDesired State βChange Only If Required74 β Understand Configuration Drift
Section titled β74 β Understand Configuration DriftβConfiguration drift occurs when systems gradually differ from their intended configuration.
Example:
VM 1Security Setting = Enabled
VM 2Security Setting = Disabled
VM 3Security Setting = Enabled75 β Automate Configuration Validation
Section titled β75 β Automate Configuration ValidationβYour script can:
Get Resources βCheck Configuration βCompare with Standard βPass / Fail76 β Build a Configuration Validation Matrix
Section titled β76 β Build a Configuration Validation Matrixβ| Resource | Expected | Actual | Status |
|---|---|---|---|
| Web-01 | Tag Present | Present | Pass |
| Web-02 | Tag Present | Missing | Fail |
| App-01 | Backup Enabled | Enabled | Pass |
77 β Detection Before Remediation
Section titled β77 β Detection Before RemediationβFor critical environments, begin with:
Detect βReport βReviewbefore:
Detect βAutomatically Change78 β Understand Automated Remediation
Section titled β78 β Understand Automated RemediationβExample:
Public Storage Detected βAutomation βChange to PrivateThis may improve security but could also:
Break ApplicationTherefore remediation needs:
Testing
Approval
Scope
Rollback
Logging79 β Understand Dry Runs
Section titled β79 β Understand Dry RunsβWhere supported:
Automation βDry Run βShow Intended Changes βNo Actual ModificationThis helps validate potentially disruptive operations.
80 β Build Your Own Preview Mode
Section titled β80 β Build Your Own Preview ModeβConceptually:
MODE=previewThen:
IF preview βPrint Action
IF execute βPerform Action81 β Understand Input Validation
Section titled β81 β Understand Input ValidationβNever blindly accept:
RESOURCE_NAMEValidate:
Is Value Present?
Does Resource Exist?
Is Environment Correct?
Is Operation Allowed?82 β Protect Production
Section titled β82 β Protect ProductionβA useful safeguard:
Environment βProduction? / \ YES NO β βRequire ContinueApproval83 β Use Explicit Resource Selection
Section titled β83 β Use Explicit Resource SelectionβPrefer:
Environment=DevelopmentANDAutoShutdown=Trueover:
All Resources84 β Understand Destructive Commands
Section titled β84 β Understand Destructive CommandsβTreat operations such as:
Delete
Terminate
Remove
Purgeas high risk.
Require additional safeguards.
85 β Build a Destructive Operation Workflow
Section titled β85 β Build a Destructive Operation WorkflowβRequest βValidate Resource βValidate Environment βCheck Dependencies βCheck Backup βApproval βExecute βVerify βLog86 β Understand Credential Security
Section titled β86 β Understand Credential SecurityβNever hardcode:
Password
API Key
Secret
Tokeninside source code where avoidable.
Poor:
PASSWORD="SuperSecret123"87 β Better Credential Handling
Section titled β87 β Better Credential HandlingβUse approved mechanisms such as:
Managed Identity
Instance Role
Service Identity
Credential Store
Secret Manager
Environment Integrationdepending on platform.
88 β Understand Secret Exposure
Section titled β88 β Understand Secret ExposureβSecrets can leak through:
Source Code
Git Repository
Logs
Command History
Screenshots
Error Messages89 β Protect Automation Logs
Section titled β89 β Protect Automation LogsβDo not log:
Passwords
Tokens
Private Keys
Secrets90 β Apply Least Privilege
Section titled β90 β Apply Least PrivilegeβIf a script only needs to:
Start+Stopdevelopment VMs, it should not automatically receive permission to:
Delete Networks
Modify IAM
Delete Databases
Change Billing91 β Use Dedicated Automation Identities
Section titled β91 β Use Dedicated Automation IdentitiesβInstead of:
Personal Administrator Account βScheduled Automationprefer:
Dedicated Automation Identity βDefined Permissions βAuditable Activity92 β Understand Separation of Duties
Section titled β92 β Understand Separation of DutiesβExample:
Developer βCreates Automation
Reviewer βReviews Automation
Operations βApproves Production DeploymentThis can reduce automation risk.
93 β Version Control Your Scripts
Section titled β93 β Version Control Your ScriptsβStore automation code in version control.
Benefits:
History
Review
Rollback
Collaboration
Traceability94 β Use Meaningful Commit History
Section titled β94 β Use Meaningful Commit HistoryβInstead of:
update scriptprefer:
Add validation before stopping development VMs95 β Test Before Production
Section titled β95 β Test Before ProductionβUse:
Development βTesting βStaging βProductionwhere your environment supports these stages.
96 β Build an Automation Test Plan
Section titled β96 β Build an Automation Test PlanβFor each script document:
Script:
Purpose:
Test Environment:
Expected Input:
Expected Action:
Expected Output:
Failure Test:
Recovery Test:
Result:97 β Test Normal Operation
Section titled β97 β Test Normal OperationβExample:
VM Running βStop Script βVM Stopped βPASS98 β Test Repeated Execution
Section titled β98 β Test Repeated ExecutionβRun again:
VM Already Stopped βStop Script βNo Harmful Change βPASSThis helps test:
idempotency.
99 β Test Invalid Resource
Section titled β99 β Test Invalid ResourceβProvide:
Resource:does-not-existExpected:
Clear Error βNo Unintended Change100 β Test Permission Failure
Section titled β100 β Test Permission FailureβUsing a controlled lab identity with insufficient permission:
Automation βPermission Denied βError Logged βSafe Exit101 β Test Partial Failure
Section titled β101 β Test Partial FailureβSuppose:
VM 1SUCCESS
VM 2FAILURE
VM 3?Decide whether the script should:
Continue
Stop
Rollbackbased on operational requirements.
102 β Understand Rollback
Section titled β102 β Understand RollbackβRollback attempts to return the environment to a previous safe state after a failed change.
Conceptually:
Change βFailure βRollback βPrevious State103 β Not Every Operation Is Easily Reversible
Section titled β103 β Not Every Operation Is Easily ReversibleβFor example:
Delete Datamay not have a simple rollback.
This makes:
Backups
Validation
Approvalespecially important.
104 β Build a Rollback Plan
Section titled β104 β Build a Rollback PlanβDocument:
Automation:
Potential Failure:
Impact:
Rollback Action:
Backup Required:
Owner:105 β Understand Automation Monitoring
Section titled β105 β Understand Automation MonitoringβAutomation itself needs monitoring.
Track:
Execution Started
Execution Completed
Execution Failed
Duration
Resources Changed
Error Count106 β Alert on Automation Failures
Section titled β106 β Alert on Automation FailuresβExample:
Scheduled Backup Automation βFAILED βAlert βCloud OperationsThis connects directly to:
Lab 20 β Cloud Alerting Lab
107 β Build the Automation Observability Model
Section titled β107 β Build the Automation Observability ModelβAutomation βExecution βLogs βMetrics βAlert βInvestigation108 β Automate Resource Inventory
Section titled β108 β Automate Resource InventoryβCreate a script that generates:
Resource Name
Resource Type
State
Region
Environment
OwnerSave the output as:
cloud-resource-inventory.csvor another structured format.
109 β Automate Cost Review Inputs
Section titled β109 β Automate Cost Review InputsβFrom Lab 21, automate detection of candidates such as:
Stopped VMs
Untagged Resources
Unattached Storage
Development Resources
Old Temporary ResourcesDo not automatically delete them.
Generate:
Optimization Candidate Report110 β Automate Tag Compliance
Section titled β110 β Automate Tag ComplianceβRequired tags:
Environment
Owner
CostCenterYour automation should output:
PASSor:
FAILfor each resource.
111 β Automate Backup Validation
Section titled β111 β Automate Backup ValidationβWhere supported, query:
Latest Backup
Backup Status
Backup TimeThen evaluate:
Successful?Recent Enough?112 β Automate Monitoring Checks
Section titled β112 β Automate Monitoring ChecksβYour script can query:
VM State
Backend Health
Backup Status
Resource Healthand generate a summary.
113 β Build an Operations Health Report
Section titled β113 β Build an Operations Health ReportβExample:
Cloud Operations Health Report
VMs:4 Running2 Stopped
Load Balancer:Healthy
Database:Available
Latest Backup:Success
Tag Compliance:92%
Automation Failures:0114 β Understand Event-Driven Automation
Section titled β114 β Understand Event-Driven AutomationβInstead of waiting for a schedule:
Event βAutomationExample:
Resource Created βValidation βMissing Tags Detected βNotification115 β Event-Driven vs Scheduled
Section titled β115 β Event-Driven vs ScheduledβScheduled:
Every Hour βCheck ResourcesEvent-driven:
Resource Changes βImmediately CheckBoth have valid use cases.
116 β Understand Automation Chains
Section titled β116 β Understand Automation ChainsβExample:
Alert βWorkflow βCollect Diagnostics βOpen Incident βNotify EngineerThis can reduce manual response time.
117 β Be Careful with Self-Healing
Section titled β117 β Be Careful with Self-HealingβSelf-healing might:
Detect Failed VM βRestart VMBut repeated restarts could hide:
Underlying Application FailureAutomation should preserve enough evidence for troubleshooting.
118 β Understand Human-in-the-Loop Automation
Section titled β118 β Understand Human-in-the-Loop AutomationβNot every workflow needs full autonomy.
Example:
Detect βGenerate Recommendation βHuman Approval βAutomation ExecutesThis is often appropriate for higher-risk operations.
119 β Automation Maturity Model
Section titled β119 β Automation Maturity ModelβYou can think of automation maturity as:
Level 1Manual
β
Level 2Scripted
β
Level 3Scheduled
β
Level 4Event-Driven
β
Level 5Policy-Driven / Self-HealingHigher maturity is not automatically better for every operation.
120 β Perform an Automation Candidate Review
Section titled β120 β Perform an Automation Candidate Reviewβ| Task | Frequency | Risk | Candidate |
|---|---|---|---|
| Dev VM Shutdown | Daily | Low | Yes |
| Resource Inventory | Daily | Low | Yes |
| Tag Validation | Daily | Low | Yes |
| Production DB Delete | Rare | Critical | No |
| Backup Validation | Daily | Low | Yes |
| Security Remediation | Event | High | Review |
121 β Perform an Automation Security Review
Section titled β121 β Perform an Automation Security ReviewβVerify:
[ ] Dedicated identity used[ ] Least privilege applied[ ] No secrets hardcoded[ ] Logs do not expose credentials[ ] Destructive actions protected[ ] Production safeguards implemented[ ] Automation activity auditable[ ] Permissions periodically reviewed122 β Perform an Automation Reliability Review
Section titled β122 β Perform an Automation Reliability ReviewβVerify:
[ ] Input validated[ ] Errors handled[ ] Exit codes checked[ ] Retries controlled[ ] Timeouts considered[ ] Partial failures handled[ ] Idempotency considered[ ] Rollback documented[ ] Execution logged[ ] Failures alerted123 β Perform an Automation Governance Review
Section titled β123 β Perform an Automation Governance ReviewβVerify:
[ ] Script owner defined[ ] Purpose documented[ ] Version controlled[ ] Changes reviewed[ ] Test process defined[ ] Production approval defined[ ] Runbook available[ ] Retirement process defined124 β Build the Findings Register
Section titled β124 β Build the Findings Registerβ| Finding | Risk | Recommendation | Priority |
|---|---|---|---|
| Manual Dev Shutdown | Unnecessary Cost | Automate Scheduling | Medium |
| Hardcoded Credentials | Credential Exposure | Use Managed Identity/Secret Store | Critical |
| Automation Uses Admin Rights | Excessive Privilege | Apply Least Privilege | Critical |
| No Error Handling | Silent Failure | Add Validation and Error Handling | High |
| No Automation Logs | Poor Troubleshooting | Implement Execution Logging | High |
| No Idempotency | Duplicate Changes | Add State Validation | High |
| No Production Safeguard | Unintended Production Change | Add Environment Validation | Critical |
| Scripts Not Version Controlled | Poor Change Tracking | Use Version Control | High |
| No Failure Alerts | Delayed Detection | Add Alerting | High |
| No Rollback Plan | Recovery Risk | Document Rollback | High |
125 β Build the Final Automation Architecture
Section titled β125 β Build the Final Automation Architectureβ Operational Requirement | v Automation Logic | +-------------+-------------+ | | v v Authentication Validation | | +-------------+-------------+ | v Cloud API | v Resource Change | +-------------+-------------+ | | v v Verification Logging | | +-------------+-------------+ | v Monitoring | v Alert | v Engineer126 β Build the Automation Runbook
Section titled β126 β Build the Automation RunbookβUse:
Runbook:Cloud Operations Automation
Automation Name:
Purpose:
Owner:
Environment:
Trigger:
Schedule:
Automation Identity:
Required Permissions:
Inputs:
Resources Affected:
Pre-Checks:
Execution Steps:
Validation:
Expected Output:
Logging:
Monitoring:
Failure Handling:
Retry Policy:
Rollback:
Escalation:
Security Controls:
Change Approval:
Testing Procedure:
Last Tested:127 β Create the Final Lab Report
Section titled β127 β Create the Final Lab ReportβUse:
Lab:Cloud Automation and Scripting Lab
Environment:
Cloud Platform:
CLI:
CLI Version:
Automation Identity:
Scripts Created:
Resource Inventory:
Start Automation:
Stop Automation:
Tag Validation:
Configuration Validation:
Backup Validation:
Scheduling:
API Operations:
Error Handling:
Retry Logic:
Logging:
Idempotency:
Credential Protection:
Least Privilege:
Testing:
Failure Testing:
Rollback:
Automation Monitoring:
Findings:
Recommendations:
Lessons Learned:π§ͺ Final Validation Checklist
Section titled βπ§ͺ Final Validation Checklistβ| Validation | Status |
|---|---|
| Cloud automation understood | |
| Automation candidates identified | |
| CLI installed/verified | |
| CLI identity validated | |
| Resource query completed | |
| Structured output reviewed | |
| Inventory script created | |
| Variables used | |
| Conditional logic understood | |
| Loops understood | |
| Exit codes understood | |
| Error handling implemented | |
| VM start automation understood | |
| VM stop automation understood | |
| Tag-driven automation understood | |
| Tag compliance automated | |
| API fundamentals understood | |
| HTTP methods understood | |
| API responses understood | |
| Throttling understood | |
| Retry logic understood | |
| Automation logging implemented | |
| Scheduling understood | |
| Idempotency understood | |
| Configuration drift understood | |
| Configuration validation performed | |
| Dry-run concept understood | |
| Input validation implemented | |
| Production safeguards understood | |
| Credential security reviewed | |
| Least privilege reviewed | |
| Dedicated automation identity understood | |
| Version control understood | |
| Test plan created | |
| Repeated execution tested | |
| Failure handling tested | |
| Rollback documented | |
| Automation monitoring understood | |
| Failure alerting understood | |
| Automation runbook created | |
| Findings documented |
π― Certification Connection
Section titled βπ― Certification ConnectionβA Cloud+ scenario may say:
Development VMs are manually stopped every evening, but engineers frequently forget.
Think:
Scheduled automation.
Another:
A script creates another VM every time it runs, even when the required VM already exists.
Think:
Idempotency problem.
Another:
An automation script contains administrator credentials directly in the source code.
Think:
Credential-management and security failure.
Another:
A script needs only to start and stop development VMs but has full administrator permissions.
Think:
Violation of least privilege.
Another:
Automation repeatedly calls a cloud API after receiving throttling errors.
Think:
Retry with controlled backoff.
Another:
An automation job fails every night but nobody notices.
Think:
Automation monitoring and failure alerting.
Another:
Engineers want automation to immediately delete every resource identified as unused.
Think:
Validate ownership, dependencies, retention, backups, and approval before destructive remediation.
π€ Interview Questions
Section titled βπ€ Interview QuestionsβPractice without notes.
1. What is cloud automation?
Section titled β1. What is cloud automation?β2. Why is automation important in cloud operations?
Section titled β2. Why is automation important in cloud operations?β3. What tasks are good candidates for automation?
Section titled β3. What tasks are good candidates for automation?β4. GUI vs CLI?
Section titled β4. GUI vs CLI?β5. What is a cloud API?
Section titled β5. What is a cloud API?β6. What is scripting?
Section titled β6. What is scripting?β7. What are variables?
Section titled β7. What are variables?β8. Why are loops useful?
Section titled β8. Why are loops useful?β9. What is conditional logic?
Section titled β9. What is conditional logic?β10. What is an exit code?
Section titled β10. What is an exit code?β11. Why is error handling important?
Section titled β11. Why is error handling important?β12. What is retry logic?
Section titled β12. What is retry logic?β13. What is exponential backoff?
Section titled β13. What is exponential backoff?β14. What is automation logging?
Section titled β14. What is automation logging?β15. What is scheduled automation?
Section titled β15. What is scheduled automation?β16. Event-driven vs scheduled automation?
Section titled β16. Event-driven vs scheduled automation?β17. What is idempotency?
Section titled β17. What is idempotency?β18. What is configuration drift?
Section titled β18. What is configuration drift?β19. What is a dry run?
Section titled β19. What is a dry run?β20. Why should automation use least privilege?
Section titled β20. Why should automation use least privilege?β21. Why shouldnβt credentials be hardcoded?
Section titled β21. Why shouldnβt credentials be hardcoded?β22. Why use dedicated automation identities?
Section titled β22. Why use dedicated automation identities?β23. Why should scripts be version controlled?
Section titled β23. Why should scripts be version controlled?β24. What is rollback?
Section titled β24. What is rollback?β25. How would you safely automate a cloud operational task?
Section titled β25. How would you safely automate a cloud operational task?βπ¨ Scenario Interview Question 1
Section titled βπ¨ Scenario Interview Question 1βDevelopment servers must run from 08:00 to 18:00 Monday through Friday.
A suitable design is:
Scheduler β08:00 Start Workflow βDevelopment Resources
18:00 Stop Workflow βDevelopment Resourcesπ¨ Scenario Interview Question 2
Section titled βπ¨ Scenario Interview Question 2βA shutdown script accidentally stops production VMs.
The automation lacks sufficient:
Resource Selection
Environment Validation
SafeguardsA better approach uses:
Environment=Development+AutoShutdown=Trueπ¨ Scenario Interview Question 3
Section titled βπ¨ Scenario Interview Question 3βA script works when executed manually but fails when scheduled.
Investigate:
Identity
Permissions
Environment Variables
Working Directory
Credentials
Execution Contextπ¨ Scenario Interview Question 4
Section titled βπ¨ Scenario Interview Question 4βAn API returns HTTP 429.
Think:
Rate limiting or throttling.
Use controlled:
Retry+Backoffπ¨ Scenario Interview Question 5
Section titled βπ¨ Scenario Interview Question 5βA script receives HTTP 403.
Think:
Authorization failure.
Review the automation identityβs permissions.
π¨ Scenario Interview Question 6
Section titled βπ¨ Scenario Interview Question 6βA resource already exists, but the script creates another one.
Improve:
Check Current State βCompare Desired State βCreate Only If Missingπ¨ Scenario Interview Question 7
Section titled βπ¨ Scenario Interview Question 7βA script automatically corrects a production security setting and causes an application outage.
This demonstrates why automated remediation requires:
Testing
Scope
Approval
Rollback
Validationπ¨ Scenario Interview Question 8
Section titled βπ¨ Scenario Interview Question 8βA script contains an API key in a Git repository.
Treat this as:
credential exposure.
The credential should be handled according to the organizationβs credential-rotation and incident-response procedures.
π¨ Scenario Interview Question 9
Section titled βπ¨ Scenario Interview Question 9βAn automation job reports success, but the resource never changed.
The script should:
Execute βVerify Actual State βReport Successrather than treating command submission as proof of success.
π¨ Scenario Interview Question 10
Section titled βπ¨ Scenario Interview Question 10βA scheduled job silently fails for five consecutive days.
The missing capabilities are:
Automation Monitoring+Failure Logging+Alertingπ§ Automation Interview Framework
Section titled βπ§ Automation Interview FrameworkβRemember:
REQUIREMENT βIS IT REPEATABLE? βDEFINE DESIRED STATE βIDENTITY βLEAST PRIVILEGE βINPUT VALIDATION βAUTOMATION βERROR HANDLING βVERIFY βLOG βMONITOR βALERT βROLLBACK βIMPROVEπ¬ Interview Tip
Section titled βπ¬ Interview TipβAvoid:
βI would write a script to automate it.β
A stronger answer is:
βI would first define the desired state and determine whether the task is sufficiently repeatable and predictable for automation. I would use a dedicated automation identity with least privilege, validate resource scope and inputs, design the workflow to be idempotent where possible, implement error handling and controlled retries, log every meaningful operation, verify the resulting resource state, test normal and failure scenarios in a non-production environment, define rollback procedures, and monitor scheduled executions so failures generate actionable alerts.β
That demonstrates Cloud Engineer and DevOps operational thinking.
π Portfolio Deliverables
Section titled βπ Portfolio DeliverablesβKeep sanitized versions of:
1. Cloud Resource Inventory Script
Section titled β1. Cloud Resource Inventory ScriptβDemonstrate:
Cloud API βScript βResource Inventory2. Development Start/Stop Automation
Section titled β2. Development Start/Stop AutomationβShow:
Scheduler βTags βDevelopment Resources βStart / Stop3. Tag Compliance Script
Section titled β3. Tag Compliance ScriptβValidate:
Environment
Owner
CostCenter4. Configuration Validation Report
Section titled β4. Configuration Validation ReportβDocument:
Expected βActual βPass / Fail5. Automation Test Report
Section titled β5. Automation Test ReportβInclude:
Normal Test
Repeated Execution
Invalid Input
Permission Failure
Partial Failure
Recovery6. Automation Security Review
Section titled β6. Automation Security ReviewβDocument:
-
identity
-
least privilege
-
credential handling
-
logging
-
production safeguards
7. Automation Runbook
Section titled β7. Automation RunbookβDocument the complete operational workflow.
π Resume Examples
Section titled βπ Resume ExamplesβInstead of:
Created cloud scripts.
Use:
Developed cloud operations automation for resource inventory, development workload scheduling, tag compliance, configuration validation, and operational health checks using cloud CLI and scripting workflows.
Or:
Built secure cloud automation workflows using dedicated identities, least-privilege permissions, input validation, error handling, execution logging, idempotent operations, testing, and failure monitoring.
Or:
Automated repetitive cloud administration tasks including VM start/stop scheduling, resource inventory, tagging validation, backup verification, and configuration checks while implementing operational safeguards and rollback procedures.
β Job-Readiness Check
Section titled ββ Job-Readiness CheckβYou should now be able to:
-
explain cloud automation
-
identify automation candidates
-
use cloud CLI concepts
-
understand cloud APIs
-
query resources
-
work with structured output
-
create basic scripts
-
use variables
-
use loops
-
use conditional logic
-
validate exit codes
-
implement error handling
-
automate VM operations
-
use tag-driven automation
-
automate resource inventory
-
automate tag compliance
-
understand scheduling
-
understand event-driven automation
-
explain idempotency
-
identify configuration drift
-
automate configuration validation
-
understand dry runs
-
validate automation inputs
-
protect production resources
-
securely handle automation credentials
-
apply least privilege
-
use dedicated automation identities
-
understand version control
-
create automation test plans
-
test failure scenarios
-
understand rollback
-
monitor automation
-
alert on automation failures
-
build operational runbooks
-
document automation findings
π Mission Complete
Section titled βπ Mission CompleteβYou have progressed from:
Engineer βManual Operation βRepeat βRepeat βRepeatto:
Operational Requirement βAutomation βValidation βCloud API βRepeatable Change βVerification βLogging βMonitoringYou now understand an important cloud operations principle:
Good automation does more than execute commands faster. It applies repeatable logic, validates scope, limits permissions, handles failure, verifies results, records activity, and reduces operational risk.
π Whatβs Next?
Section titled βπ Whatβs Next?βYou have now learned how to automate individual cloud operations.
The next progression is managing the configuration and deployment of entire cloud environments as code.
Instead of:
Script βCreate Resource A
Script βConfigure Resource B
Script βConfigure Resource Cyou will begin working with:
Infrastructure Definition βVersion Control βValidation βDeployment βRepeatable InfrastructureIn the next lab, you will work with:
-
Infrastructure as Code fundamentals
-
declarative infrastructure
-
templates
-
desired state
-
repeatable deployments
-
variables and parameters
-
outputs
-
dependencies
-
version control
-
configuration validation
-
deployment planning
-
configuration drift
-
reusable templates
-
secure IaC practices
-
deployment testing
-
infrastructure lifecycle management
β‘οΈ Next: Lab 23 β Infrastructure as Code (IaC) Lab