Skip to main content

Posts

Showing posts from December, 2020

How will you make Aurora to communicate with a Lambda?

Step 1: Create an IAM policy as follows: { "Version": "2012-10-17", "Statement": [ { "Sid": "AllowAuroraToLambdaFunction", "Effect": "Allow", "Action": "lambda:InvokeFunction", "Resource": "arn:aws:lambda:<REGION>:<ACCOUNT_NO>:function:<FUNCTION_NAME>" } ] } Step 2: Create an IAM role and attach the policy above and have the trust policy as follows: { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "rds.amazonaws.com" }, "Action": "sts:AssumeRole" } ] } Step 3: Link the above IAM role with the Aurora DB cluster Step 4: Allow outbound communication from Aurora C...

Ports

Ports: 22 - SSH 80 - HTTP 443 - HTTPS 1433 - Microsoft SQL Server 1434   - Microsoft SQL  Monitor 3306 - MySQL DB System 3389 - Microsoft RDP 5432 - PostgreSQL

AWS Aurora

What are the two modes of Aurora you can have? MySQL PostgreSQL What are the different Database locations you can provision your Aurora DB with? Regional - Provision Aurora DB in a single AWS region Global - In multiple AWS regions. It has primary & secondary regions. Data written in DB in primary region gets replicated in the secondary regions in < 1 sec. How will you achieve fast failover/high availability? Through Multi-AZ deployment Can you backup Aurora DB? Yes, by creating point-in-time snapshots. We can set up retention period for these backups. We can also copy tags to snapshots. Can you encrypt data in Aurora DB? Yes. You can use the KMS keys . I have added few incorrect data and I want to go back to my previous good state in Aurora DB. How would I achieve this? You can quickly rewind to a specific point-in-time by Enabling Backtrack. But, this will cost you to save the changes you made for backtracking. What are the various DB features available in Aurora DB? One wri...

AWS S3 Cross Region Replication

What are the constraints to enable S3 cross region replication? To enable cross region replication, you should have two buckets: Bucket 1 - should be in region A Bucket 2 - should be in region B Versioning should be enabled in both the buckets for replication. Can you create same region replication? Yes Can you create cross account replication? Yes Can you replicate a subset of objects using replication? Yes, you can limit the scope of the replication rules to specific prefixed/tags etc., You can also apply the rules to all the objects in the bucket What is the expected delay in copying the files from the source to destination buckets in S3 replication? A few seconds. Can you replicate only the new objects? The new objects can be replicated after enabling the replication rule. However, the already existing objects can also be replicated by enabling Replicate existing objects option.

AWS VPC Flow Logs

You can find the IP addresses where requests to your VPC Network Interfaces are coming from through the VPC Flow Logs . These logs can be published in S3/CloudWatch . You can also view/query the data through Athena .

AWS EBS

DeleteOnTermination attribute: The EC2 instances will have Root EBS volumes. When you terminate an EC2 instance, the Root EBS volume will also get deleted. To prevent this, set the DeleteOnTermination attribute, for the EBS volume, to false. This will prevent the EBS volume from being deleted even when the EC2 instance is terminated. A comparison of EBS volume types: General Purpose SSD  - recommended for most workloads Provisioned IOPS SSD  - use this when the required number of input/output operations per second is high (10000 IOPS or 160 MiB/s of throughput per volume) Throughput Optimized HDD   - use this for a fast throughput at a lower price Cold SSD  - use for large volumes of data which are in frequently accessed Where are the snapshots stored? In S3. Can you directly create a snapshot in another region? No. You have to create a snapshot in the same region and copy that snapshot to another region. Is it safe to copy the snapshot to another region? What if oth...

Availability Zone Disruption

Availability Zones (AZs) are nothing but data centers within a region. For example, North Virginia has the maximum of 6 AZs. An AZ is geographically separated from another AZ. Suppose a natural calamity, like earthquake occurs, in the region of an AZ, say 1A, the entire AZ will not be available. This is called Availability Zone Disruption . In such cases, we should make our applications highly available by scaling them across other AZs. Minimum good number of AZs is 2.

High availability (Multi-AZ) for Amazon RDS

There is something called failover technology in Amazon. AWS RDS's Multi-AZ deployment uses this technology. If you enable Multi-AZ for an RDS DB, say MySQL DB, RDS automatically creates a standby replica in a different AZ. If the primary DB instance is in AZ-1A, then RDS creates a standby replica in AZ-1B (for example). Suppose I add a new row to a table in the primary DB, then the same row is added, almost in the same time, in the standby replica. This is called as synchronous replication . Thus, standby replicas are useful during DB instance failure/ AZ disruption . How? Because, there is no need to create a backup later because the backup has already been created. This gives high availability during planned system maintenance. Normal backup  operation - I/O activities are blocked in the primary database  Automated backup operation (standby replica) - I/O activities are not blocked This standby replica is not similar to read replica (which is used for disaster recovery). S...

AWS CloudTrail

AWS CloudTrail is an API monitoring service.  It records activities in your account. We can log those activities in S3 bucket It gives visibility to user activities e.g., if you want to know who created an EC2 instance, you can get the answer using CloudTrail Using CloudTrail, you can track changes to AWS resources in your accounts

useCallback hook

Check the code below: usecallback-demo-1-component-renders-unnecessarily - Code You can run the app directly: usecallback-demo-1-component-renders-unnecessarily - App Whenever the button is clicked, the 'increment rendered' message is logged in console. This means, we're rendering the  Increment  component unnecessarily. The Increment component is rendered every time  à  because it depends on  increment  method  à  this method again depends on  count  state  à  so, whenever the  count  state changes, since  count  state is a dependency of  Increment  component, this must be rendered everytime. However, consider the following code where this problem is solved (of course using random number instead of count for demo): usecallback-demo-2-usecallback-prevents-unnecessary-renders - Code Here, we're caching the  increment  method using  useCallback  hook. The  Inc...

CDK - Error: unable to determine cloud assembly asset output directory. Assets must be defined indirectly within a "Stage" or an "App" scope

Cause: Got this error after executing  1) `npm install @aws-cdk/aws-lambda` 2) `cdk diff` --> threw error This is because of the version mismatch of @aws-cdk/aws-lambda package against @aws-cdk/core. The package.json file looked like this: "dependencies": {     "@aws-cdk/aws-lambda": "^1.78.0",     "@aws-cdk/aws-sns": "1.49.1",     "@aws-cdk/aws-sns-subscriptions": "1.49.1",     "@aws-cdk/aws-sqs": "1.49.1",     "@aws-cdk/core": "1.49.1"   } Fix: Updated the package.json file as follows: "dependencies": {     "@aws-cdk/aws-lambda": " 1.49.1 ", --> changed here     "@aws-cdk/aws-sns": "1.49.1",     "@aws-cdk/aws-sns-subscriptions": "1.49.1",     "@aws-cdk/aws-sqs": "1.49.1",     "@aws-cdk/core": "1.49.1"   } And then running `npm i` fixed the issue. From next time ...

How to create a react application and push in a new Git repo?

Create a repo called my-app in Github npx create-react-app my-app --template typescript git remote add origin https://github.com/<YOUR-GIT-NAME>/my-app.git Control panel --> Credential manager --> Windows credentials --> remove all Git credentials (otherwise, you will get 403) git config user.name "<YOUR-NAME>" git config user.email <EMAIL-ADDRESS> git config -e git checkout -b main git branch -D master git branch git fetch origin main git pull origin main --allow-unrelated-histories Fix all merge conflicts through VS Code git commit git push --set-upstream origin main