# Multi-operation Prompts

This page describes multi-operation prompts which can be used to trigger more than one operations in a single prompt where all operations can be either ec2 operations or lightsail operations or a mixture of operations from ec2 and lightsail.

### Examples

#### Creating a vpc with a child subnet

```
create a vpc with '10.101.0.0/16' cidr
  create a subnet with '10.101.1.0/24' cidr
```

Adding two spaces in front of a line will establish parent / child relationship between this resource and the resource created by the previous line. Otherwise all the resources will be provisioned without any relationship with each other.

#### Creating a security group and adding ingress rules to it

```
create a security group with following details -
name - securitygroup-ssh-https
description - Allow access on ssh and https ports
-----
  add following ingress rules -
  22|tcp|192.168.1.1
  443|tcp|192.168.2.0/24
```

#### Listing vpcs and subnets

```
list all the vpcs
list all the subnets
```

#### Provisioning a Lightsail Docker host

```
import a lightsail key pair with following details -
name - key1
key - <public_key_content>
-----
create a lightsail vm with following details -
name(s) - instance1
zone - eu-west-1a
blueprint - ubuntu_24_04
bundle - nano_3_0
ssh key - key1
user data - "curl -fsSL https://raw.githubusercontent.com/mechcloud/sample-scripts/refs/heads/main/install-docker.sh | bash"
-----
replace firewall rules of 'instance1' lightsail vm with following -
22|tcp|@CURRENT_IP
443|tcp|@CURRENT_IP
```

**Troubleshooting user data**&#x20;

* Check user-data file content -

```
sudo cat /var/lib/cloud/instance/user-data.txt
```

* Check cloud-init logs -

```
sudo cat /var/log/cloud-init-output.log
```

#### Query multiple resources required for provisioning an EC2 VM

```
list images
list instance types which are free tier eligible
list ec2 key pairs
-----
list security groups with following name -
securitygroup-ssh-https
```

#### Provisioning an EC2 Docker host

<mark style="color:red;">**At this moment base64\_encode function is not supported in the prompt. It has been mentioned here to inform the user that the data should be manually base64 encoded and updated in place of base64\_ecode() function call.**</mark>

```
import an ec2 key pair with following details -
name - <key_name>
key - base64_encode(<key_content>)
-----
create a security group with following details -
name - <sg_name>
description - Allow access on ssh
-----
  add following ingress rules -
  22|tcp|@CURRENT_IP
-----
create an ec2 vm with following details -
ami - <ami_id>
instance type - <instance_type>
key - <key_name>
security group - <sg_id>
user data - base64_encode("#!/bin/bash\ncurl -fsSL https://raw.githubusercontent.com/mechcloud/sample-scripts/refs/heads/main/install-docker.sh | bash")
```

#### Trigger a lightsail operation on multiple resources even though AWS API supports performing this operation on one resource at a time

```
reboot following lightsail VMs -
instance1
instance2
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mechcloud.io/ai-agents/aws-agent/multi-operation-prompts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
