0% found this document useful (0 votes)
14 views4 pages

Dotnet + Aws + Postgre SQL + Angular Cheatsheet

Cheatsheet .NET core and aws

Uploaded by

Harsh Mendapara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

Dotnet + Aws + Postgre SQL + Angular Cheatsheet

Cheatsheet .NET core and aws

Uploaded by

Harsh Mendapara
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

🔥 Cheatsheet: .

NET Core + AWS + PostgreSQL + Angular

🔹 1. Tech Stack Overview

• Frontend: Angular (UI & HTTP communication)


• Backend: .NET Core Web API (business logic, security, API endpoints)
• Database: PostgreSQL (hosted locally, on RDS, or Aurora)
• Cloud: AWS (services like Lambda, S3, RDS, SQS, SNS)

🔹 2. Project Structure Suggestion

Solution/
├── API/ (ASP.NET Core Web API)
├── Infrastructure/ (Data, AWS SDK, PostgreSQL context)
├── Application/ (CQRS, Services, Interfaces)
├── AngularApp/ (Angular UI)

🔹 3. Connecting .NET Core with PostgreSQL (EF Core)

• NuGet: Npgsql.EntityFrameworkCore.PostgreSQL

dotnet add package Npgsql.EntityFrameworkCore.PostgreSQL

• DbContext Example:

public class AppDbContext : DbContext


{
public DbSet<User> Users { get; set; }
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
{ }
}

• Startup Configuration:

builder.Services.AddDbContext<AppDbContext>(options =>
options.UseNpgsql(builder.Configuration.GetConnectionString("Default")));

1
🔹 4. Basic Angular Integration

• Service for HTTP calls:

@Injectable({ providedIn: 'root' })


export class UserService {
private apiUrl = 'https://your-api.com/api/users';
constructor(private http: HttpClient) {}

getUsers(): Observable<User[]> {
return this.http.get<User[]>(this.apiUrl);
}
}

• Component:

ngOnInit() {
this.userService.getUsers().subscribe(data => this.users = data);
}

🔹 5. Use AWS Services with .NET Core

• Upload file to S3:

var fileTransfer = new TransferUtility(_s3Client);


await fileTransfer.UploadAsync(fileStream, "my-bucket", "file-name.txt");

• Publish SNS message:

await _snsClient.PublishAsync(new PublishRequest {


TopicArn = topicArn,
Message = "New user registered"
});

• Insert DB row after SQS trigger:

public async Task FunctionHandler(SQSEvent evnt, ILambdaContext context) {


foreach (var message in evnt.Records) {
var data = JsonSerializer.Deserialize<UserDto>(message.Body);
_dbContext.Users.Add(new User { Name = data.Name });
await _dbContext.SaveChangesAsync();

2
}
}

🔹 6. Deployment Tips

• Angular → Build and upload to S3 (static hosting)


• .NET Core → Deploy using Elastic Beanstalk, ECS Fargate, or Lambda
• PostgreSQL → Use Amazon RDS or Aurora
• Secure config via AWS Systems Manager Parameter Store or Secrets Manager

🔹 7. API Gateway + Lambda (.NET)

• Use Amazon.Lambda.AspNetCoreServer NuGet package


• Convert Web API to Lambda-compatible handler:

public class LambdaEntryPoint : APIGatewayProxyFunction


{
protected override void Init(IWebHostBuilder builder) {
builder.UseStartup<Startup>();
}
}

🔹 8. Security Best Practices

• Angular: Sanitize inputs, use environment files, JWT in Authorization header


• .NET: Use AddAuthentication().AddJwtBearer()
• PostgreSQL: Use parameterized queries or EF Core
• AWS: Use IAM roles for Lambda/ECS and secure access to RDS

🔹 9. Common Integration Flow

Angular → .NET Core API → PostgreSQL (RDS)


→ AWS S3 (upload)
→ SNS (alerts)
→ SQS (async flow)
→ Lambda (background tasks)

3
🔹 10. Tools You’ll Use

Purpose Tool/Service

HTTP Client Angular HttpClient

Backend API .NET Core Web API

DB Access EF Core + Npgsql

File Storage Amazon S3

Messaging Amazon SQS / SNS

Serverless Execution AWS Lambda

Hosting Angular S3 + CloudFront (CDN)

Monitoring AWS CloudWatch

Secrets AWS Secrets Manager / Parameter Store

Let me know if you want this in PDF format or want to link it with your real project structure (e.g., DUNS
Tracker or Survey App).

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy