Skip to content

Commit 7767994

Browse files
authored
Merge pull request #1 from lkdavies/lkdavies-gs
Getting started tutorials
2 parents e5406e8 + 892db67 commit 7767994

18 files changed

Lines changed: 3995 additions & 0 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# AWS Marketplace buyer getting started
2+
3+
This tutorial demonstrates how to get started as a buyer on AWS Marketplace, covering the essential steps to discover, evaluate, and subscribe to software products. You'll learn how to navigate the marketplace, understand pricing models, manage subscriptions, and integrate purchased software into your AWS environment.
4+
5+
You can either run the automated shell script (`marketplace-buyer-getting-started.sh`) to quickly set up the necessary AWS resources and configurations, or follow the step-by-step instructions in the tutorial (`marketplace-buyer-getting-started.md`) to manually complete each task and gain a deeper understanding of the AWS Marketplace buyer experience.
Lines changed: 331 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,331 @@
1+
# Getting started with AWS Marketplace using the AWS CLI
2+
3+
This tutorial guides you through common AWS Marketplace buyer operations using the AWS Command Line Interface (AWS CLI). You'll learn how to search for products, launch an EC2 instance with a product AMI, and manage your subscriptions.
4+
5+
**Alternative title:** Using the AWS CLI to find and deploy AWS Marketplace products
6+
7+
## Topics
8+
9+
* [Prerequisites](#prerequisites)
10+
* [Searching for products](#searching-for-products)
11+
* [Creating resources for your instance](#creating-resources-for-your-instance)
12+
* [Launching an instance](#launching-an-instance)
13+
* [Managing your software](#managing-your-software)
14+
* [Cleaning up resources](#cleaning-up-resources)
15+
* [Going to production](#going-to-production)
16+
* [Next steps](#next-steps)
17+
18+
## Prerequisites
19+
20+
Before you begin this tutorial, make sure you have the following.
21+
22+
1. The AWS CLI. If you need to install it, follow the [AWS CLI installation guide](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html). You can also [use AWS CloudShell](https://docs.aws.amazon.com/cloudshell/latest/userguide/welcome.html), which includes the AWS CLI.
23+
2. Configured your AWS CLI with appropriate credentials. Run `aws configure` if you haven't set up your credentials yet.
24+
3. Basic familiarity with command line interfaces and SSH concepts.
25+
4. [Sufficient permissions](https://docs.aws.amazon.com/marketplace/latest/buyerguide/buyer-security-iam-awsmanpol.html) to access AWS Marketplace and create EC2 resources in your AWS account.
26+
5. Estimated time to complete: 30-45 minutes.
27+
6. Estimated cost: Approximately $0.0116 for running a t2.micro EC2 instance for one hour. If you choose a paid AWS Marketplace product, additional charges may apply based on the product's pricing model.
28+
29+
Let's get started with exploring AWS Marketplace and launching software using the CLI.
30+
31+
## Searching for products
32+
33+
AWS Marketplace offers a wide range of software products that you can deploy on AWS. In this section, you'll learn how to search for products using the AWS CLI.
34+
35+
**List available AMI products**
36+
37+
The following command lists available AMI products in AWS Marketplace.
38+
39+
```
40+
aws marketplace-catalog list-entities \
41+
--catalog "AWSMarketplace" \
42+
--entity-type "AmiProduct"
43+
```
44+
45+
This command returns a list of AMI products available in AWS Marketplace. The response includes details such as product IDs, names, and descriptions.
46+
47+
**Search for specific products**
48+
49+
If you're looking for a specific type of product, you can use the list-entities command with a query string.
50+
51+
```
52+
aws marketplace-catalog list-entities \
53+
--catalog "AWSMarketplace" \
54+
--entity-type "AmiProduct" \
55+
--query "WordPress"
56+
```
57+
58+
This command searches for WordPress-related AMI products in AWS Marketplace. You can replace "WordPress" with any keyword relevant to your needs.
59+
60+
**Get details about a specific product**
61+
62+
Once you've found a product you're interested in, you can get more details about it using the describe-entity command.
63+
64+
```
65+
aws marketplace-catalog describe-entity \
66+
--catalog "AWSMarketplace" \
67+
--entity-id "entity-id"
68+
```
69+
70+
Replace `entity-id` with the actual entity ID of the product you want to learn more about. This command provides comprehensive information about the product, including its features, pricing, and usage instructions.
71+
72+
## Creating resources for your instance
73+
74+
Before launching an instance with your chosen AWS Marketplace product, you need to create some supporting resources. This section guides you through creating a key pair and security group.
75+
76+
**Create a key pair for SSH access**
77+
78+
The following command creates a new SSH key pair and saves the private key to your local machine.
79+
80+
```
81+
aws ec2 create-key-pair \
82+
--key-name marketplace-tutorial-key \
83+
--query 'KeyMaterial' \
84+
--output text > marketplace-tutorial-key.pem
85+
```
86+
87+
After running this command, the private key is saved to your current directory. Next, set the appropriate permissions for the key file.
88+
89+
```
90+
chmod 400 marketplace-tutorial-key.pem
91+
```
92+
93+
This ensures that only you can read the private key file, which is a security requirement for SSH. Store this key file securely and never share it or check it into version control systems.
94+
95+
**Get your default VPC ID**
96+
97+
For better resource organization, we'll get your default VPC ID to use when creating the security group.
98+
99+
```
100+
aws ec2 describe-vpcs \
101+
--filters "Name=isDefault,Values=true" \
102+
--query "Vpcs[0].VpcId" \
103+
--output text
104+
```
105+
106+
Note the VPC ID from the output for the next step.
107+
108+
**Create a security group**
109+
110+
The following command creates a new security group for your instance in your default VPC.
111+
112+
```
113+
aws ec2 create-security-group \
114+
--group-name marketplace-tutorial-sg \
115+
--description "Security group for AWS Marketplace tutorial" \
116+
--vpc-id vpc-id
117+
```
118+
119+
Replace `vpc-id` with the VPC ID you obtained in the previous step. The response includes the security group ID, which you'll need for the next steps.
120+
121+
**Configure security group rules**
122+
123+
For this tutorial, we'll restrict SSH access to your current IP address for better security.
124+
125+
```
126+
aws ec2 authorize-security-group-ingress \
127+
--group-name marketplace-tutorial-sg \
128+
--protocol tcp \
129+
--port 22 \
130+
--cidr $(curl -s https://checkip.amazonaws.com)/32
131+
```
132+
133+
This command allows SSH access only from your current IP address, which is more secure than allowing access from anywhere.
134+
135+
For HTTP access, which might be needed depending on the product you're deploying:
136+
137+
```
138+
aws ec2 authorize-security-group-ingress \
139+
--group-name marketplace-tutorial-sg \
140+
--protocol tcp \
141+
--port 80 \
142+
--cidr $(curl -s https://checkip.amazonaws.com)/32
143+
```
144+
145+
This restricts HTTP access to your current IP address as well. For a production environment, you would configure these rules differently based on your specific requirements.
146+
147+
## Launching an instance
148+
149+
Now that you have the necessary resources in place, you can launch an EC2 instance with your chosen AWS Marketplace product. This section shows you how to launch and connect to your instance.
150+
151+
**Get the AMI ID**
152+
153+
For this tutorial, we'll use an Amazon Linux 2 AMI as an example. In a real scenario, you would use the AMI ID from your chosen AWS Marketplace product.
154+
155+
```
156+
aws ec2 describe-images \
157+
--owners amazon \
158+
--filters "Name=name,Values=amzn2-ami-hvm-2.0.*-x86_64-gp2" "Name=state,Values=available" \
159+
--query "sort_by(Images, &CreationDate)[-1].ImageId" \
160+
--output text
161+
```
162+
163+
This command retrieves the latest Amazon Linux 2 AMI ID. Note the AMI ID from the output for the next step.
164+
165+
**Launch an EC2 instance**
166+
167+
The following command launches an EC2 instance using the AMI ID, key pair, and security group you created earlier.
168+
169+
```
170+
aws ec2 run-instances \
171+
--image-id ami-abcd1234 \
172+
--instance-type t2.micro \
173+
--key-name marketplace-tutorial-key \
174+
--security-group-ids sg-abcd1234 \
175+
--count 1
176+
```
177+
178+
Replace `ami-abcd1234` with the actual AMI ID you obtained in the previous step and `sg-abcd1234` with your security group ID. The response includes details about your new instance, including its instance ID.
179+
180+
**Check instance status**
181+
182+
You can check the status of your instance using the describe-instances command.
183+
184+
```
185+
aws ec2 describe-instances \
186+
--filters "Name=instance-state-name,Values=running" \
187+
--query "Reservations[*].Instances[*].[InstanceId,State.Name,PublicDnsName]" \
188+
--output table
189+
```
190+
191+
This command lists all your running instances along with their IDs, states, and public DNS names. Wait until your instance is in the "running" state before proceeding.
192+
193+
**Connect to your instance**
194+
195+
Once your instance is running, you can connect to it via SSH using the key pair you created earlier.
196+
197+
```
198+
ssh -i marketplace-tutorial-key.pem ec2-user@your-instance-public-dns
199+
```
200+
201+
Replace `your-instance-public-dns` with the actual public DNS name of your instance from the previous command's output. The username might be different depending on the AMI you're using.
202+
203+
## Managing your instances
204+
205+
After launching your instance, you can monitor it.
206+
207+
**Monitor your EC2 instances**
208+
209+
You can monitor your running instances with the following command.
210+
211+
```
212+
aws ec2 describe-instances \
213+
--filters "Name=image-id,Values=ami-abcd1234" \
214+
--query "Reservations[*].Instances[*].[InstanceId,State.Name,PublicDnsName]" \
215+
--output table
216+
```
217+
218+
Replace `ami-abcd1234` with the actual AMI ID of your instance. This command shows all instances launched with that specific AMI.
219+
220+
## Cleaning up resources
221+
222+
When you're finished with your AWS Marketplace resources, you should clean them up to avoid incurring additional charges. This section shows you how to terminate your instance and delete associated resources.
223+
224+
**Terminate your instance**
225+
226+
The following command terminates your EC2 instance.
227+
228+
```
229+
aws ec2 terminate-instances \
230+
--instance-ids i-1234abcd
231+
```
232+
233+
Replace `i-1234abcd` with the actual instance ID of your instance. The response confirms that the termination process has started.
234+
235+
**Wait for instance termination**
236+
237+
Before deleting the security group, wait for the instance to fully terminate.
238+
239+
```
240+
aws ec2 wait instance-terminated --instance-ids i-1234abcd
241+
```
242+
243+
Replace `i-1234abcd` with your actual instance ID. This command will wait until the instance is fully terminated.
244+
245+
**Delete your security group**
246+
247+
After your instance is terminated, you can delete the security group.
248+
249+
```
250+
aws ec2 delete-security-group \
251+
--group-name marketplace-tutorial-sg
252+
```
253+
254+
This command deletes the security group you created earlier. Make sure all instances using this security group are terminated before attempting to delete it.
255+
256+
**Delete your key pair**
257+
258+
Finally, delete the key pair you created.
259+
260+
```
261+
aws ec2 delete-key-pair \
262+
--key-name marketplace-tutorial-key
263+
```
264+
265+
This command deletes the key pair from AWS. You can also delete the local copy of your private key if you no longer need it.
266+
267+
```
268+
rm marketplace-tutorial-key.pem
269+
```
270+
271+
## Going to production
272+
273+
This tutorial is designed to help you learn how to use AWS Marketplace and EC2 via the AWS CLI. For production environments, consider the following additional best practices:
274+
275+
### Security considerations
276+
277+
1. **Network segmentation**: Create a custom VPC with public and private subnets, placing your instances in private subnets when possible.
278+
2. **IAM roles**: Use IAM roles instead of access keys for EC2 instances to access AWS services.
279+
3. **Security groups**: Implement the principle of least privilege by only opening necessary ports to specific IP ranges.
280+
4. **HTTPS**: Configure HTTPS with proper certificates for any web applications.
281+
5. **Security monitoring**: Implement AWS Security Hub, GuardDuty, and CloudTrail for comprehensive security monitoring.
282+
283+
### Architecture best practices
284+
285+
1. **High availability**: Deploy across multiple Availability Zones for resilience.
286+
2. **Auto Scaling**: Implement Auto Scaling groups to handle varying loads.
287+
3. **Infrastructure as Code**: Use AWS CloudFormation or AWS CDK to define and provision resources.
288+
4. **Monitoring and observability**: Set up CloudWatch metrics, logs, and alarms.
289+
5. **Cost optimization**: Use resource tagging, consider reserved instances or Savings Plans, and implement automated resource cleanup.
290+
291+
For more information on building production-ready systems on AWS, refer to:
292+
- [AWS Well-Architected Framework](https://docs.aws.amazon.com/wellarchitected/latest/framework/welcome.html)
293+
- [AWS Security Best Practices](https://docs.aws.amazon.com/whitepapers/latest/aws-security-best-practices/welcome.html)
294+
- [AWS Architecture Center](https://aws.amazon.com/architecture/)
295+
296+
## Troubleshooting
297+
298+
Here are solutions to common issues you might encounter during this tutorial:
299+
300+
**Permission errors with marketplace-catalog commands**
301+
302+
If you receive permission errors when running marketplace-catalog commands, ensure your IAM user or role has the appropriate permissions. You may need to attach the `AWSMarketplaceFullAccess` managed policy or create a custom policy with specific marketplace-catalog permissions.
303+
304+
**Security group deletion fails**
305+
306+
If you can't delete a security group because it's still associated with an instance, ensure all instances using the security group are fully terminated. You can check this with:
307+
308+
```
309+
aws ec2 describe-instances \
310+
--filters "Name=instance.group-name,Values=marketplace-tutorial-sg" \
311+
--query "Reservations[*].Instances[*].[InstanceId,State.Name]" \
312+
--output table
313+
```
314+
315+
**SSH connection issues**
316+
317+
If you can't connect to your instance via SSH, check:
318+
1. The instance is in the "running" state
319+
2. You're using the correct key file and username
320+
3. Your security group allows SSH access from your current IP address
321+
4. The instance has a public IP address
322+
323+
## Next steps
324+
325+
Now that you've learned the basics of using AWS Marketplace with the AWS CLI, explore these additional features:
326+
327+
1. [Private marketplace](https://docs.aws.amazon.com/marketplace/latest/buyerguide/private-marketplace.html) - Create a curated digital catalog of pre-approved products for your organization.
328+
2. [Procurement systems integration](https://docs.aws.amazon.com/marketplace/latest/buyerguide/procurement-systems-integration.html) - Connect AWS Marketplace to your procurement systems.
329+
3. [License management](https://docs.aws.amazon.com/marketplace/latest/buyerguide/license-management.html) - Manage licenses for your AWS Marketplace software.
330+
4. [Container products](https://docs.aws.amazon.com/marketplace/latest/buyerguide/container-products.html) - Deploy container-based applications from AWS Marketplace.
331+
5. [SaaS products](https://docs.aws.amazon.com/marketplace/latest/buyerguide/saas-products.html) - Subscribe to and use Software as a Service products from AWS Marketplace.

0 commit comments

Comments
 (0)