Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära AWS SDKs & CLI for Developers | AWS Development Fundamentals
AWS Certified Developer - Associate

bookAWS SDKs & CLI for Developers

Introduction

This module covers how developers use the AWS Command Line Interface (CLI) and Software Development Kits (SDKs) to interact with AWS programmatically. While the AWS Management Console is great for manual tasks, it's not ideal for scaling, automation, or integrating AWS services into production apps.

Mastering the CLI and SDKs is crucial for deploying infrastructure, managing services, or building cloud-native applications on AWS.

Why Use the CLI or SDK Instead of the AWS Console?

The AWS Console offers a user-friendly, graphical interface — but it has limitations:

  • It's manual, requiring point-and-click interaction;
  • It's slow, especially for repetitive or bulk tasks;
  • It's not scalable, making automation difficult.

As a developer, you'll want to:

  • Automate infrastructure and workflows;
  • Interact with AWS from your code editor or terminal;
  • Build repeatable deployment processes.

The CLI and SDKs empower you to achieve all of this. They allow you to write scripts, integrate AWS services directly into your applications, and avoid unnecessary context switching between the browser and development environment.

CLI vs SDK: What's the Difference?

Summary:

  • CLI: Great for scripting and infrastructure automation;
  • SDK: Best for application-level integration with AWS services.

Working with the AWS CLI

Step 1: Configure Your AWS CLI

Before using the CLI, you need to authenticate your AWS account:

aws configure

You'll be prompted to enter:

  1. Access Key ID – get this from your AWS account security credentials;
  2. Secret Access Key – a secure key associated with your access key ID;
  3. Default Region – e.g., us-east-1;
  4. Default Output Format – e.g., json, or leave as default.
Note
Note

You should never hard-code credentials in production scripts. Use roles or environment variables when possible.

Step 2: Create an S3 Bucket

aws s3 mb s3://your-unique-bucket-name

Notes:

  • Bucket names must be globally unique;
  • They must not contain capital letters;
  • If the bucket name already exists, the command will fail.

Step 3: Upload a File to S3

First, create a dummy file (e.g., mozart_mix.mp3):

touch "mozart_mix.mp3"

Then upload it:

aws s3 cp mozart_mix.mp3 s3://your-unique-bucket-name

You can verify the upload:

aws s3 ls s3://your-unique-bucket-name

This lists the contents of the bucket, including the uploaded file.

Using the AWS SDK (JavaScript Example)

If you're building an application and want to interact with S3 programmatically, use the AWS SDK. Here's an example in JavaScript:

Step 1: Import Required Modules

import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";

Step 2: Initialize the S3 Client

const s3 = new S3Client({ region: "us-east-1" });

Step 3: Define the Upload Parameters

const uploadParams = {
  Bucket: "your-unique-bucket-name",
  Key: "profile-picture.png",         // Name of the object in S3
  Body: fileBuffer,                   // File content, e.g. from form upload
  ContentType: "image/png",           // Optional but useful
};

Step 4: Upload the Object

const command = new PutObjectCommand(uploadParams);
await s3.send(command);

This command uploads the file to the S3 bucket. You can use this code as part of a feature such as user profile image upload, which is common in modern applications.

Final Thoughts

The CLI and SDK are two powerful tools that let you interact with AWS the developer way:

  • Use the CLI for automation, scripting, and infrastructure operations;
  • Use SDKs for integrating AWS into your application logic.

Although we'll occasionally use the AWS Console for demonstration purposes, your real productivity comes from mastering these programmatic tools.

As you continue with this course, expect to use both the CLI and SDK extensively. It may seem intimidating at first, but with practice, it becomes second nature—and much faster and safer than using the AWS UI for most tasks.

1. What is the main difference between AWS CLI and AWS SDK?

2. Why shouldn't you hard-code AWS credentials in your app?

3. Which CLI command uploads 'resume.pdf' to 'my-app-bucket'?

4. Which command sets default AWS credentials and region?

5. Which class uploads a file using the AWS SDK (JavaScript)?

question mark

What is the main difference between AWS CLI and AWS SDK?

Select the correct answer

question mark

Why shouldn't you hard-code AWS credentials in your app?

Select the correct answer

question mark

Which CLI command uploads 'resume.pdf' to 'my-app-bucket'?

Select the correct answer

question mark

Which command sets default AWS credentials and region?

Select the correct answer

question mark

Which class uploads a file using the AWS SDK (JavaScript)?

Select the correct answer

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 1

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

Awesome!

Completion rate improved to 6.25

bookAWS SDKs & CLI for Developers

Svep för att visa menyn

Introduction

This module covers how developers use the AWS Command Line Interface (CLI) and Software Development Kits (SDKs) to interact with AWS programmatically. While the AWS Management Console is great for manual tasks, it's not ideal for scaling, automation, or integrating AWS services into production apps.

Mastering the CLI and SDKs is crucial for deploying infrastructure, managing services, or building cloud-native applications on AWS.

Why Use the CLI or SDK Instead of the AWS Console?

The AWS Console offers a user-friendly, graphical interface — but it has limitations:

  • It's manual, requiring point-and-click interaction;
  • It's slow, especially for repetitive or bulk tasks;
  • It's not scalable, making automation difficult.

As a developer, you'll want to:

  • Automate infrastructure and workflows;
  • Interact with AWS from your code editor or terminal;
  • Build repeatable deployment processes.

The CLI and SDKs empower you to achieve all of this. They allow you to write scripts, integrate AWS services directly into your applications, and avoid unnecessary context switching between the browser and development environment.

CLI vs SDK: What's the Difference?

Summary:

  • CLI: Great for scripting and infrastructure automation;
  • SDK: Best for application-level integration with AWS services.

Working with the AWS CLI

Step 1: Configure Your AWS CLI

Before using the CLI, you need to authenticate your AWS account:

aws configure

You'll be prompted to enter:

  1. Access Key ID – get this from your AWS account security credentials;
  2. Secret Access Key – a secure key associated with your access key ID;
  3. Default Region – e.g., us-east-1;
  4. Default Output Format – e.g., json, or leave as default.
Note
Note

You should never hard-code credentials in production scripts. Use roles or environment variables when possible.

Step 2: Create an S3 Bucket

aws s3 mb s3://your-unique-bucket-name

Notes:

  • Bucket names must be globally unique;
  • They must not contain capital letters;
  • If the bucket name already exists, the command will fail.

Step 3: Upload a File to S3

First, create a dummy file (e.g., mozart_mix.mp3):

touch "mozart_mix.mp3"

Then upload it:

aws s3 cp mozart_mix.mp3 s3://your-unique-bucket-name

You can verify the upload:

aws s3 ls s3://your-unique-bucket-name

This lists the contents of the bucket, including the uploaded file.

Using the AWS SDK (JavaScript Example)

If you're building an application and want to interact with S3 programmatically, use the AWS SDK. Here's an example in JavaScript:

Step 1: Import Required Modules

import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";

Step 2: Initialize the S3 Client

const s3 = new S3Client({ region: "us-east-1" });

Step 3: Define the Upload Parameters

const uploadParams = {
  Bucket: "your-unique-bucket-name",
  Key: "profile-picture.png",         // Name of the object in S3
  Body: fileBuffer,                   // File content, e.g. from form upload
  ContentType: "image/png",           // Optional but useful
};

Step 4: Upload the Object

const command = new PutObjectCommand(uploadParams);
await s3.send(command);

This command uploads the file to the S3 bucket. You can use this code as part of a feature such as user profile image upload, which is common in modern applications.

Final Thoughts

The CLI and SDK are two powerful tools that let you interact with AWS the developer way:

  • Use the CLI for automation, scripting, and infrastructure operations;
  • Use SDKs for integrating AWS into your application logic.

Although we'll occasionally use the AWS Console for demonstration purposes, your real productivity comes from mastering these programmatic tools.

As you continue with this course, expect to use both the CLI and SDK extensively. It may seem intimidating at first, but with practice, it becomes second nature—and much faster and safer than using the AWS UI for most tasks.

1. What is the main difference between AWS CLI and AWS SDK?

2. Why shouldn't you hard-code AWS credentials in your app?

3. Which CLI command uploads 'resume.pdf' to 'my-app-bucket'?

4. Which command sets default AWS credentials and region?

5. Which class uploads a file using the AWS SDK (JavaScript)?

question mark

What is the main difference between AWS CLI and AWS SDK?

Select the correct answer

question mark

Why shouldn't you hard-code AWS credentials in your app?

Select the correct answer

question mark

Which CLI command uploads 'resume.pdf' to 'my-app-bucket'?

Select the correct answer

question mark

Which command sets default AWS credentials and region?

Select the correct answer

question mark

Which class uploads a file using the AWS SDK (JavaScript)?

Select the correct answer

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 1
some-alt