Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

Using CLI commands with Amazon Q Developer - Common use cases

Focus mode
Using CLI commands with Amazon Q Developer - Common use cases - Amazon Q Developer in chat applications

AWS Chatbot is now Amazon Q Developer. Learn more

AWS Chatbot is now Amazon Q Developer. Learn more

Common use cases for using Amazon Q Developer in your chat channels involve running CLI commands. This topic also includes an example use case for invoking a Lambda function in your chat channel, written in Python 3.8.

For more information about running CLI commands in chat channels see Running AWS CLI commands from chat channels using Amazon Q Developer.

For a tutorial that walks you through how to invoke Lambda functions from Amazon Q Developer, see the Tutorial: Using Amazon Q Developer to run an AWS Lambda function remotely.

Restart an Amazon EC2 instance

The following example shows how CLI commands can be used to restart your specified Amazon EC2 instance from your chat channel. The parameters you include here are your instance id, min, and max size. For more information about restarting Amazon EC2 instances, see the reboot-instances command in the AWS CLI Command Reference.

@Amazon Q ec2 reboot-instances --instance-ids i-1234567890abcdef5

Change Auto Scaling limits

The following example shows how CLI commands can be used to change your Auto Scaling limits directly from your chat channel. The parameters you include are the name of your Auto Scaling group and the minimum and maximum sizes. For more information about changing autoscaling limits, see update-autoscaling-group command in the AWS CLI Command Reference.

@Amazon Q autoscaling update-auto-scaling-group --auto-scaling-group-name my-asg --min-size 2 --max-size 10

Run an Automation runbook

The following example shows how CLI commands can be used to run an Automation runbook. In this command you specify your document name and your parameters. For more information, see the start-automation-execution command in the AWS CLI Command Reference.

@Amazon Q ssm start-automation-execution --document-name "AWS-UpdateLinuxAmi" --parameters "AutomationAssumeRole=arn:aws:iam::123456789012:role/SSMAutomationRole,SourceAmiId=ami-EXAMPLE,IamInstanceProfileName=EC2InstanceRole"

Use a Lambda function to approve an AWS CodePipeline action

The code example in this section demonstrates how you can use a Lambda function to perform activities, spefically how you can manually approve a pipeline action. This function enables you to approve or reject a pipeline action from your chat channel by entering the status and a summary. The function gets the required token using the get_pipeline_status method. It then uses the token value when applying the approval decision by using the put_approval_result method. For more information about these methods, see the CodePipeline section of the Boto3 docs 1.14.10 documentation. The Lambda code uses Python 3.8.

import boto3 def lambda_handler(event, context): client = boto3.client('codepipeline') getToken = client.get_pipeline_state( name = 'mypipeline1' ) myToken=getToken['stageStates']['actionStates']['latestExecution']['token'] response = client.put_approval_result( pipelineName='mypipeline1', stageName='beta', actionName='Approval', result={ 'summary': ['summary'], 'status': ['status'] }, token=myToken )

The following Amazon Q Developer command invokes the Lambda function. For more information about CodePipeline and pipeline actions, see the AWS CodePipeline User Guide.

@Amazon Q invoke mypipeline1-beta-Approval --payload {"summary": "the design looks good, ready to release",“status”: "Approved"}

PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.