Using AWS CLI from Angular, React, Node.js, Java & C#
Part 1: What Is the AWS Console?
AWS Console is a web-based GUI to manage all your AWS services. You can:
- Launch EC2 instances
- Create S3 buckets
- Manage IAM roles
- Set up Lambda functions
- …and much more
Use it when you want an intuitive, click-and-go interface.
Good for exploration, small tweaks, and visualization.
Visit: https://console.aws.amazon.com
Part 2: What Is the AWS CLI?
The AWS CLI (Command Line Interface) is a command-driven tool that allows you to control AWS services via terminal commands or scripts.
- Best for automation
- CI/CD pipelines
- Scriptable infrastructure
Part 3: Installing AWS CLI
Mac/Linux/Windows
Install via:
curl "<a href="https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" target="_blank" rel="noreferrer noopener">https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip</a>" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
Or use a package manager like:
brew install awscli # macOS
choco install awscli # Windows
Configure
aws configure
You’ll be prompted to enter:
- AWS Access Key ID
- AWS Secret Access Key
- Region
- Output format (e.g., json)
Useful AWS CLI Examples
List S3 Buckets
aws s3 ls
Upload a file to S3
aws s3 cp ./file.txt s3://my-bucket-name/
Start an EC2 Instance
aws ec2 start-instances --instance-ids i-0123456789abcdef0
Part 4: Using AWS CLI in Code (via SDKs)
Let’s explore how different frontend & backend platforms can work with AWS via CLI or SDK.
Angular / React
Use Amplify or the AWS SDK via a backend proxy. Frontends can’t call the AWS CLI directly (security risk).
Option 1: Use Amplify in React
npm install aws-amplify
// App.js (React)
import Amplify from 'aws-amplify';
import awsExports from './aws-exports';
Amplify.configure(awsExports);
// Call a Lambda function
import { API } from 'aws-amplify';
API.get('myApi', '/items')
.then(data => console.log(data))
.catch(err => console.error(err));
Option 2: Use AWS CLI via a Backend API Proxy
# Backend does:
aws s3 cp ./input.json s3://my-bucket/input.json
Your frontend just makes HTTP calls to the backend.
Node.js
Use child_process
to invoke CLI or use the SDK.
Option 1: AWS CLI from Node
const { exec } = require('child_process');
exec('aws s3 ls', (err, stdout, stderr) => {
if (err) throw err;
console.log(stdout);
});
Option 2: Use AWS SDK
npm install aws-sdk
const AWS = require('aws-sdk');
const s3 = new AWS.S3();
s3.listBuckets((err, data) => {
if (err) console.error(err);
else console.log(data.Buckets);
});
Java Example
Add dependency (Maven):
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
<version>2.25.13</version>
</dependency>
Code Example
S3Client s3 = S3Client.builder().region(Region.US_EAST_1).build();
ListBucketsResponse buckets = s3.listBuckets();
buckets.buckets().forEach(b -> System.out.println(<a href="http://b.name/" target="_blank" rel="noreferrer noopener">b.name</a>()));
C# (.NET)
Install NuGet package:
dotnet add package AWSSDK.S3
Code Example
var client = new AmazonS3Client();
var response = await client.ListBucketsAsync();
foreach (var bucket in response.Buckets)
{
Console.WriteLine(bucket.BucketName);
}
Summary
Platform | Approach | Recommended Tool/SDK |
---|---|---|
Angular | Amplify, backend proxy | Amplify / API Gateway |
React | Amplify, backend proxy | Amplify / SDK |
Node.js | CLI or SDK | aws-sdk |
Java | AWS SDK v2 | software.amazon.awssdk |
C# / .NET | AWS SDK for .NET | AWSSDK.* |
Final Tips
- Use IAM Roles for permission management
- Never expose AWS CLI/keys on the frontend
- For frontend integration, prefer Cognito + API Gateway + Lambda
- For automation, use AWS CLI + Bash/Node scripts