A DevOps team wants to write a shell script to automate the daily starting and stopping of Amazon EC2 instances based on a schedule. The script must parse output in JSON format and run from an administrative machine without requiring a full programming language runtime. Additionally, the team needs to audit who initiated these start/stop actions. Which combination of AWS tool and service best meets these requirements?
- AAWS Management Console to execute the start/stop actions, and Amazon GuardDuty to audit the API calls
- AWS CLI to script the start/stop actions, and AWS CloudTrail to audit the API callsAnswer
- CAWS SDK to script the actions, and Amazon CloudWatch to audit the API calls
- DAWS Elastic Beanstalk to script the actions, and AWS Systems Manager to audit the API calls
Answer
AWS CLI to script the start/stop actions, and AWS CloudTrail to audit the API calls
The AWS CLI is the optimal tool for executing administrative commands and shell scripts on AWS resources without the overhead of a full programming language runtime. It native-formats command outputs in JSON, which makes parsing straightforward. AWS CloudTrail is the designated AWS service to monitor, log, and audit account API activity, ensuring the team has visibility into who triggered the start and stop API operations.
Step-by-Step Solution
Key Concept
Selecting the appropriate AWS interface tool (CLI vs. SDK vs. Console) based on execution requirements, and identifying the correct operational monitoring and auditing service (CloudTrail vs. CloudWatch).
Alternative Method
While a Python script using the AWS SDK (Boto3) could perform this automation, the team specifically required a solution without a programming language runtime environment. Thus, utilizing the AWS CLI within a shell script is the most direct and lightweight path.
Estimated Time:2m 0s