<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Martin Sobrero on Medium]]></title>
        <description><![CDATA[Stories by Martin Sobrero on Medium]]></description>
        <link>https://medium.com/@martin-sobrero-m?source=rss-f4de80fd34ba------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RQQuMYbXiY1d53_VnB-uVw.jpeg</url>
            <title>Stories by Martin Sobrero on Medium</title>
            <link>https://medium.com/@martin-sobrero-m?source=rss-f4de80fd34ba------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 23:41:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@martin-sobrero-m/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[GetItem vs QueryTable vs ScanTable]]></title>
            <link>https://martin-sobrero-m.medium.com/getitem-vs-querytable-vs-scantable-3778d6cef5a1?source=rss-f4de80fd34ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/3778d6cef5a1</guid>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <dc:creator><![CDATA[Martin Sobrero]]></dc:creator>
            <pubDate>Fri, 04 Sep 2026 12:29:57 GMT</pubDate>
            <atom:updated>2026-09-04T12:29:57.005Z</atom:updated>
            <content:encoded><![CDATA[<p>I usually get confused when needing to get data from a DynamoDb table in AWS. I just need to &quot;SELECT&quot; from the table “WHERE&quot; some filters apply, which command should I use?</p><p>I that happens to you too, this document is for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/0*sqEX4BsPJ6g1TmaE.png" /></figure><p>There are three ways of getting data from a table in DynamoDb:</p><h3><strong>1. GetItem</strong></h3><p>Using all the necessary keys to get one specific Item. If there is only a partition key, that is all you need to get it. If there is also a sort key, you will need to provide it so the function can return only one Item, remember that when there is a combination of partition and sort key, both combined are the unique key. More on partition keys <a href="https://aws.amazon.com/blogs/database/choosing-the-right-dynamodb-partition-key/">here</a>.</p><p>Let&#39;s look at the following example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PhC2QAP7uAWQ3MGXn9-DXg.png" /></figure><p>In this table of games, where the publishers are the partition key and the titles are the sort key, to get a unique item you need to use both of the keys (as shown in green). Just using the partition key or the sort key may reference more than one item, making the command GetItem return an error.</p><p>Code example:</p><pre>import {<br>  DynamoDBClient,<br>} from &#39;@aws-sdk/client-dynamodb&#39;;<br>import {<br>  GetCommand,<br>  GetCommandOutput,<br>  DynamoDBDocumentClient,<br>} from &#39;@aws-sdk/lib-dynamodb&#39;;<br><br>const client = new DynamoDBClient({<br>  region: &#39;REGION&#39;,<br>});<br>const docClient = DynamoDBDocumentClient.from(client);<br><br>const command: GetCommand = new GetCommand({<br>  TableName: &#39;TABLE_NAME&#39;,<br>  Key: {<br>    pk,<br>    sk,<br>  },<br>});<br><br>const { Item }: GetCommandOutput = await this.docClient.send(command);</pre><h3>2. QueryTable</h3><p>Used for retrieving multiple items by their primary key, with an optional sort key to order the results.</p><p>It also has the possibility to add more filters but that reading capacity will be charged as well as it is done after searching the database. Using the previous example, if you search using the partition key EA and then use a filter for NintendoDS, AWS will charge you for reading 3 rows, even though the query will only return one.</p><p>This method can also be used with GSI (Global Secondary Indexes) in the same way used with partition and sort keys.</p><p>Code example:</p><pre>import {<br>  QueryCommand,<br>} from &#39;@aws-sdk/client-dynamodb&#39;;<br>import { marshall, unmarshall } from &#39;@aws-sdk/util-dynamodb&#39;;<br><br>const command: QueryCommand = new QueryCommand({<br>  TableName: &#39;TABLE_NAME&#39;,<br>  KeyConditionExpression: &#39;#publisher = :publisher&#39;,<br>  ExpressionAttributeNames: {<br>    &#39;#publisher&#39;: &#39;publisher&#39;,<br>  },<br>  ExpressionAttributeValues: marshall({<br>    &#39;:publisher&#39;: publisher,<br>  }),<br>});<br>const { Items } = docClient.send(command);<br>result = Items?.map(item =&gt; unmarshall(item))[0];</pre><h3>3. ScanTable</h3><p>Used for retrieving multiple items by iterating through all of them. It is the less efficient way of retrieving items and can be both expensive and slow.</p><p>It allows pagination and optional filtering, but similarly to the Query method, these filters are still charged with reading capacity.</p><p>Code example:</p><pre>import {<br>  ScanCommand,<br>} from &#39;@aws-sdk/lib-dynamodb&#39;;<br><br>const command = new ScanCommand({<br>  TableName: &#39;TABLE_NAME&#39;,<br>  ExpressionAttributeValues: {<br>    :p: { S: &quot;EA&quot; }<br>  },<br>  FilterExpression: &quot;publisher = :p&quot;,<br>});<br>const { Items } = await docClient.send(command);<br>if (!Items || Items.length === 0) {<br>  return [];<br>}<br>const result = Items.map(item =&gt; unmarshall(item));</pre><p>I hope this simple guide helps you remember all three different methods of getting data from DynamoDb.</p><p><strong>More info:</strong></p><ul><li>Get item [<a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_GetItem.html">link</a>]</li><li>Query tables [<a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Query.html">link</a>]</li><li>Scan tables [<a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html">link</a>]</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3778d6cef5a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get all result Items from the scan method in DynamoDb]]></title>
            <link>https://martin-sobrero-m.medium.com/get-all-result-items-from-the-scan-method-in-dynamodb-cb21f924ad42?source=rss-f4de80fd34ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb21f924ad42</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[dynamodb]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Martin Sobrero]]></dc:creator>
            <pubDate>Mon, 07 Aug 2023 20:37:48 GMT</pubDate>
            <atom:updated>2023-08-07T20:37:48.013Z</atom:updated>
            <content:encoded><![CDATA[<p>Probably many of us were in the situation where we need to get a lot of items from a DynamoDb database using the scan method but the result is does not have all the items it should. To solve this issue we are going to run the scan method as many times as needed until we have all the results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/0*_BGuP7EcfSEDrmbx.png" /></figure><p>Today we are going to solve this issue using a Lambda function, the NodeJs library <a href="https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/index.html">sdk-v3</a> from AWS, and a DynamoDb with a lot of items. The configuration of the Lambda and the DynamoDb is not in the scope of this document.</p><h3>The implementation</h3><p>First lets create the simple method for scanning the DynamoDb based on two dates, dateFrom and dateTo. To do this we need to install some dependencies:</p><ul><li><a href="https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-dynamodb/">@aws-sdk/client-dynamodb</a>: Where the database client and the commands are.</li><li><a href="https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/modules/_aws_sdk_util_dynamodb.html">@aws-sdk/util-dynamodb</a>: Dynamo returns the objects with its &quot;marshall&quot; format. To format these objects into common JSON objects we need the method unmarshall.</li></ul><p>$ npm i @aws-sdk/client-dynamodb @aws-sdk/util-dynamodb</p><p>Then lets create a new service method that scans the table.</p><pre>const { DynamoDBClient, ScanCommand } = require(&quot;@aws-sdk/client-dynamodb&quot;);<br>const { unmarshall } = require(&quot;@aws-sdk/util-dynamodb&quot;);<br><br>const client = new DynamoDBClient({});<br><br>/**<br> * <br> * @param {object} data<br> * @param {string} data.dateFrom<br> * @param {string} data.dateTo<br> */<br>async function scanErrors({ dateFrom, dateTo }) {<br>    let input = {<br>        TableName: process.env.ERRORS_TABLE,<br>        ExpressionAttributeValues: {<br>            &quot;:df&quot;: { S: `${dateFrom}` },<br>            &quot;:dt&quot;: { S: `${dateTo}` },<br>        },<br>        ExpressionAttributeNames: {<br>            &quot;#date&quot;: &quot;date&quot;<br>        },<br>        FilterExpression: &quot;#date &gt;= :df and #date &lt;= :dt&quot;<br>    };<br><br>    const command = new ScanCommand(input);<br>    const response = await client.send(command);<br><br>    return response.Items.map(i =&gt; unmarshall(i));<br>}<br><br>module.exports = {<br>    scanErrors,<br>};</pre><p>The only problem with this code is that it may not return all the Items that meet the requirements. If we log the object response we are going to see something like this:</p><pre>{<br>    &quot;Count&quot;: 296,<br>    &quot;Items&quot;: [<br>        { ... }<br>    ],<br>    &quot;LastEvaluatedKey&quot;: {<br>        &quot;id&quot;: {<br>            &quot;S&quot;: &quot;&lt;id&gt;&quot;<br>        },<br>        &quot;date&quot;: {<br>            &quot;S&quot;: &quot;1689721316154&quot;<br>        }<br>    },<br>    &quot;ScannedCount&quot;: 1056<br>}</pre><p>From the response we can see that:</p><ul><li>Count: The count of Items retrieved.</li><li>Items: Each item received.</li><li>LastEvaluatedKey: Used for pagination. The response reached the maximum size of 1MB.</li><li>ScannedCount: The cout of items scanned, some of them did not meet the requirements of the filter.</li></ul><p>So now lets address the real problem, getting all the Items that meet the requirement. To do this we have to check if there is a LastEvaluatedKey and if there is, use it in the scan command like follows.</p><pre>async function scanErrors({ dateFrom, dateTo }) {<br>    let input = {<br>        TableName: process.env.ERRORS_TABLE,<br>        ExpressionAttributeValues: {<br>            &quot;:df&quot;: { S: `${dateFrom}` },<br>            &quot;:dt&quot;: { S: `${dateTo}` },<br>        },<br>        ExpressionAttributeNames: {<br>            &quot;#date&quot;: &quot;date&quot;<br>        },<br>        FilterExpression: &quot;#date &gt;= :df and #date &lt;= :dt&quot;<br>    };<br><br>    let results = [];<br>    let lastKey;<br><br>    do {<br>        if (lastKey) {<br>            input.ExclusiveStartKey = lastKey;<br>        } else {<br>            delete input.ExclusiveStartKey;<br>        }<br><br>        const command = new ScanCommand(input);<br>        const { LastEvaluatedKey, Items } = await client.send(command);<br>        lastKey = LastEvaluatedKey;<br>        results.push(...Items);<br>    } while (lastKey);<br><br>    return results.map(i =&gt; unmarshall(i));<br>}</pre><p>What we added to the previous code:</p><ul><li>A list of results to keep adding them for each scan that we make.</li><li>The value of the last key evaluated, in case there is one.</li><li>Do-While: To scan the database at least once, and keep doing it until there is no LastEvaluatedKey, which means the scan evaluated all keys.</li><li>Push the items to the list of results</li><li>Save the LastEvaluatedKey to validate in the next iteration.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*GUZVLEEMmxiMVbgpQ3Rhqg.png" /></figure><p>If we run the code again we will see that the response has all the items. One way to test it is by logging the LastEvaluatedKey, as we can see in the following screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2C-u57fUn4JRZMEAo4xX9g.png" /></figure><p>And that is it! Now we have an easy way of getting all the items from a DynamoDb using the scan method.</p><h3>More info</h3><ul><li><a href="https://stackoverflow.com/questions/44589967/how-to-fetch-scan-all-items-from-aws-dynamodb-using-node-js">How to fetch/scan all items from `AWS dynamodb` using node.js</a></li><li><a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html">Working with scans in DynamoDB</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb21f924ad42" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloud Practitioner: Security]]></title>
            <link>https://martin-sobrero-m.medium.com/cloud-practitioner-security-d8bc868d3071?source=rss-f4de80fd34ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8bc868d3071</guid>
            <category><![CDATA[certification]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-cloud-practitioner]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Martin Sobrero]]></dc:creator>
            <pubDate>Sun, 15 Jan 2023 22:10:24 GMT</pubDate>
            <atom:updated>2023-01-15T22:10:24.805Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the sixth module in the series of documents that helped me pass the “Cloud Practitioner” certification. You can find the other modules here:</p><ul><li>Introduction to AWS [<a href="https://martin-sobrero-m.medium.com/cloud-practitioner-introduction-to-aws-1609cceaf163">Link</a>]</li><li>Compute in the cloud [<a href="https://awstip.com/cloud-practitioner-compute-in-the-cloud-3f5c94576b67">Link</a>]</li><li>Global infrastructure and reliability [<a href="https://martin-sobrero-m.medium.com/cloud-practitioner-global-infrastructure-and-reliability-22b3ba3249be">Link</a>]</li><li>Networking [<a href="https://medium.com/aws-tip/cloud-practitioner-networking-21d0fb512811">Link</a>]</li><li>Storage &amp; Database [<a href="https://awstip.com/cloud-practitioner-storage-database-2499aca8659a">Link</a>]</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*utR8wcC5ep_3BUHt.png" /></figure><h3>AWS shared responsibility model</h3><p>AWS is responsible for the security of some parts of your environment and you (the customer) are responsible for other parts. It is divided into:</p><ul><li>Customer responsibilities (“security in the cloud”): Customers are responsible for the security of everything that they create and put in the AWS Cloud. The user is responsible for IAM roles and identities that can invoke the AWS Lambda functions. Client side data encryption, patch guest OS. When using AWS services, you maintain complete control over the content. You are responsible for managing security requirements for your content, including which content you choose to store on AWS, which AWS services you use, and who has access to that content. You also control how access rights are granted, managed, and revoked.</li><li>AWS responsibilities (“security of the cloud”): AWS operates, manages, and controls the components at all layers of infrastructure. This includes areas such as the host operating system, the virtualization layer, and even the physical security of the data centers from which services operate. AWS is responsible for protecting the global infrastructure that runs all of the services offered in the AWS Cloud. This infrastructure includes AWS Regions, Availability Zones, and edge locations.</li></ul><h3>AWS Identity and Access Management (IAM)</h3><p>Document that enables you to manage access to AWS services and resources securely. IAM gives you the flexibility to configure access based on your company’s specific operational and security needs. It is free of cost.</p><h3>AWS account root user</h3><p>When you first create an AWS account, you begin with an identity known as the root user. It has complete access to all the AWS services and resources in the account.</p><h3>IAM users</h3><p>An IAM user is an identity (represents the person or application) that you create in AWS. It consists of a name and credentials. By default, when you create a new IAM user in AWS, it has no permissions associated with it. To allow the IAM user to perform specific actions in AWS, you must grant the IAM user the necessary permissions.</p><h3>IAM policies</h3><p>Is a document that allows or denies permissions to AWS services and resources.</p><h3>IAM groups</h3><p>An IAM group is a collection of IAM users. When you assign an IAM policy to a group, all users in the group are granted permissions specified by the policy. IAM roles: For getting temporary security credentials IAM tags: Labels for custom attributes. Key-value pair.</p><h3>AWS Organizations</h3><p>You can use AWS Organizations to consolidate and manage multiple AWS accounts within a central location. When you create an organization, AWS Organizations automatically creates a root, which is the parent container for all the accounts in your organization.</p><p>In AWS Organizations, you can centrally control permissions for the accounts in your organization by using service control policies (SCPs). SCPs enable you to place restrictions on the AWS services, resources, and individual API actions that users and roles in each account can access.</p><p>SCPs can be used in Organizational Units and in an individual member account. Can be automated.</p><h3>Organizational units</h3><p>In AWS Organizations, you can group accounts into organizational units (OUs) to make it easier to manage accounts with similar business or security requirements. When you apply a policy to an OU, all the accounts in the OU automatically inherit the permissions specified in the policy. Can only have one parent.</p><h3>AWS Artifact</h3><p>AWS Artifact is a service that provides on-demand access to AWS security and compliance reports and select online agreements. AWS Artifact consists of two main sections:</p><ul><li>Agreements: You can review, accept, and manage agreements for an individual account and for all your accounts in AWS Organizations. Different types of agreements are offered.</li><li>Reports: Provide compliance reports from third-party auditors. These auditors have tested and verified that AWS is compliant with a variety of global, regional, and industry-specific security standards and regulations.</li></ul><h3>Customer Compliance Center</h3><p>Contains resources to help you learn more about AWS compliance.</p><h3>Denial-of-service attacks (DoS)</h3><p>It is a deliberate attempt to make a website or application unavailable to users.</p><p>Distributed denial-of-service attacks: Multiple sources are used to start an attack that aims to make a website or application unavailable.</p><h3>AWS Shield</h3><p>A service that protects applications against DDoS attacks. Route 53, Cloudfront and Load balancing also help in this. AWS Shield provides two levels of protection:</p><ul><li>Standard: Automatically protects all AWS customers at no cost. It protects your AWS resources from the most common, frequently occurring types of DDoS attacks. As network traffic comes into your applications, a variety of analysis techniques is used to detect malicious traffic in real time and automatically mitigates it.</li><li>Advanced: Is a paid service that provides detailed attack diagnostics and the ability to detect and mitigate sophisticated DDoS attacks.</li></ul><h3>AWS Key Management Service (AWS KMS)</h3><p>Enables you to perform encryption operations through the use of cryptographic keys. You can use AWS KMS to create, manage, and use cryptographic keys. You can also control the use of keys across a wide range of services and in your applications. Uses envelope encryption while integrating with other AWS services.</p><p>A cryptographic key is a random string of digits used for locking (encrypting) and unlocking (decrypting) data.</p><p>With AWS KMS, you can choose the specific levels of access control that you need for your keys. For example, you can specify which IAM users and roles are able to manage keys. Alternatively, you can temporarily disable keys so that they are no longer in use by anyone. Your keys never leave AWS KMS, and you are always in control of them.</p><p>AWS managed KMS keys can only be rotated automatically as compared to the Customer Managed KMS keys that can be rotated automatically or manually.</p><h3>Amazon Inspector</h3><p>Helps to improve the security and compliance of applications by running automated security assessments. It checks applications for security vulnerabilities and deviations from security best practices. After the Amazon Inspector has performed an assessment, it provides you with a list of security findings.</p><p>Amazon Inspector provides two types of packages. Network reachability rules package checks network accessibility checks on Amazon EC2 instance. Host assessment rules package checks vulnerabilities on Amazon EC2 instances. Uses predefined templates.</p><h3>Amazon GuardDuty</h3><p>It is a service that provides intelligent threat detection for your AWS infrastructure and resources. It identifies threats by continuously monitoring the network activity and account behavior within your AWS environment, including S3.</p><h3>Other services</h3><p>AWS WAF: It is a web application firewall that lets you monitor network requests that come into your web applications.</p><p>Bastion Host Overview: Bastion means a structure for Fortification to protect things behind it. In AWS, a Bastion host can be used to securely access instances in the private subnets. They need to be created in multiple AZ for redundancy.</p><p>Certificate Manager: Allows the web administrator to maintain one or several SSL/TLS certificates. To verify one: a CNAME record would need to be created and the administrator would need to acknowledge a verification email.</p><p>Cloud HSM: Allows for the administrator to have full and exclusive control over the generation and management cryptographic keys on actual hardware security modules that are physically stored in AWS data centers.</p><p>Cognito: Lets you add user sign-up, sign-in, and access control to your web and mobile apps quickly and easily. Supports sign-in with social identity providers, such as Apple, Facebook, Google, and other login services.</p><p>Encryption SDK: Improves implementation of the client-side encryption.</p><p>Firewall manager: Can manage VPC security groups, AWS Shield Advanced and WAF rules on one platform even across multiple AWS accounts. Since the DB does not require a Public IP, it is always a good practice to host the DB server on a non-default subnet that does not allocate a public IP by default. Also, the DB server should not have a route to the internet gateway.</p><p>Identity Federation: So users can access the AWS environment using their active directory credentials. It is possible for users to log into the AWS environment using their Facebook, Twitter or LinkedIn login credentials.</p><p>Secrets Manager: Easy way to safely store encrypted credentials and perform on demand retrieval.</p><p>Security hub: Facilitates the view of high priority security alerts. provides a view of across-account security status and gives security alerts.</p><p>Security Token service: web service that enables you to request temporary, limited-privilege credentials for AWS IAM users or for users that you authenticate (federated users). Mobile apps need access to AWS resources. STS + Identity federation = Session</p><p>Single Sign-On (SSO): Simplifies access management and manages access to multiple AWS accounts and business applications centrally.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8bc868d3071" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloud Practitioner: Storage & Database]]></title>
            <link>https://awstip.com/cloud-practitioner-storage-database-2499aca8659a?source=rss-f4de80fd34ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/2499aca8659a</guid>
            <category><![CDATA[certification]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws-cloud-practitioner]]></category>
            <dc:creator><![CDATA[Martin Sobrero]]></dc:creator>
            <pubDate>Sat, 17 Dec 2022 18:24:05 GMT</pubDate>
            <atom:updated>2022-12-23T11:28:44.902Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the fifth module in the series of documents that helped me pass the “Cloud Practitioner” certification. You can find the other modules here:</p><ul><li>Introduction to AWS [<a href="https://martin-sobrero-m.medium.com/cloud-practitioner-introduction-to-aws-1609cceaf163">Link</a>]</li><li>Compute in the cloud [<a href="https://awstip.com/cloud-practitioner-compute-in-the-cloud-3f5c94576b67">Link</a>]</li><li>Global infrastructure and reliability [<a href="https://martin-sobrero-m.medium.com/cloud-practitioner-global-infrastructure-and-reliability-22b3ba3249be">Link</a>]</li><li>Networking [<a href="https://medium.com/aws-tip/cloud-practitioner-networking-21d0fb512811">Link</a>]</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*DmYV96ikE5fr-0zy.png" /></figure><h3>Instance stores</h3><p>Block-level storage volumes behave like physical hard drives. An instance store provides temporary block-level storage for an Amazon EC2 instance. An instance store is disk storage that is physically attached to the host computer for an EC2 instance, and therefore has the same lifespan as the instance. When the instance is terminated, you lose any data in the instance store.</p><p>Amazon Elastic Block Store (Amazon EBS) is a service that provides block-level storage volumes. If you stop or terminate an Amazon EC2 instance, all the data on the attached EBS volume remains available.</p><p>To create an EBS volume, you define the configuration (such as volume size and type) and provision it. After you create an EBS volume. Because EBS volumes are for data that needs to persist, it’s important to back up the data. You can take incremental backups of EBS volumes by creating Amazon EBS snapshots. It is replicated in the same Availability Zone.</p><h3>Amazon EBS snapshots</h3><p>An EBS snapshot is an incremental backup. This means that the first backup taken of a volume copies all the data. For subsequent backups, only the blocks of data that have changed since the most recent snapshot are saved. In full backups, all the data in a storage volume copies each time a backup occurs. Store snapshots on S3 can help reduce costs. Responsibility of the customer.</p><p>Data is not saved in backups outside a region unless you configure it that way. EBS snapshots are customer’s responsibility.</p><h3>Object storage</h3><p>In object storage, each object consists of data, metadata, and a key.</p><ul><li>The data might be an image, video, text document, or any other type of file.</li><li>Metadata contains information about what the data is, how it is used, the object size, and so on. Instance metadata is the defined parameters and attributes specified in instance configuration. User data is information that is passed to the instance’s operating system to automatically execute during boot time.</li><li>An object’s key is its unique identifier.</li></ul><h3>Amazon Simple Storage Service (Amazon S3)</h3><p>A service that provides object-level storage. Amazon S3 stores data as objects in buckets. Amazon S3 offers unlimited storage space. The maximum file size for an object in Amazon S3 is 5 TB (<em>Virtually unlimited storage</em>).</p><p>When you upload a file to Amazon S3, you can set permissions to control visibility and access to it. You can also use the Amazon S3 versioning feature to track changes to your objects over time. Lifecycle transition requests (GET/PUT) are paid, but the number of buckets do not add cost.</p><p>By default, a user can only access resources they created. S3 supports both server-side and client-side encryptions.</p><h3>Amazon S3 storage classes</h3><p>With Amazon S3, you pay only for what you use. You can choose from a range of storage classes to select a fit for your business and cost needs. When selecting an Amazon S3 storage class, consider these two factors: How often you plan to retrieve your data &amp; How available you need your data to be.</p><ul><li>S3 Standard: Provides high availability for objects. Has a higher cost than other storage classes intended for infrequently accessed data and archival storage. Stores data in a minimum of three Availability Zones. Object versioning and lifecycle policies (obj transition to other storage class after time).</li><li>S3 Standard-Infrequent Access (S3 Standard-IA): Ideal for infrequently accessed data. Similar to S3 Standard but has a lower storage price and higher retrieval price. Stores data in a minimum of three Availability Zones.</li><li>S3 One Zone-Infrequent Access (S3 One Zone-IA): Stores data in a single Availability Zone</li><li>S3 Intelligent-Tiering: Ideal for data with unknown or changing access patterns. Requires a small monthly monitoring and automation fee per object. If you haven’t accessed an object for 30 consecutive days, Amazon S3 automatically moves it to the infrequent access tier, S3 Standard-IA. If you access an object in the infrequent access tier, Amazon S3 automatically moves it to the frequent access tier, S3 Standard.</li><li>S3 Glacier: Low-cost storage designed for data archiving. Able to retrieve objects within a few minutes to hours</li><li>S3 Glacier Deep Archive: Lowest-cost object storage class ideal for archiving. Able to retrieve within 12 hours</li></ul><h3>Athena</h3><p>Is a serverless query service used to analyze BigData stored in S3. It queries data directly from Amazon S3 and there are no additional data storage commitments beyond the object storage. It is compatible with data formats such as CSV, JSON, ORC, AVRO and Parquet.</p><h3>File storage</h3><p>In file storage, multiple clients can access data that is stored in shared file folders. In this approach, a storage server uses block storage with a local file system to organize files. Clients access data through file paths.</p><p>Compared to block storage and object storage, file storage is ideal for use cases in which a large number of services and resources need to access the same data at the same time.</p><p>Amazon Elastic File System (Amazon EFS) is a serverless scalable file system used with AWS Cloud services and on-premises resources. As you add and remove files, Amazon EFS grows and shrinks automatically. It can scale on demand without disrupting applications. Stores data <em>across multiple Availability Zone</em>. Up to petabytes. You can also share files between thousands of Amazon EC2 instances and on-premises servers via AWS Direct Connect or AWS VPN. <em>Regional offering</em>.</p><h3>Relational databases</h3><p>In a relational database, data is stored in a way that relates it to other pieces of data. Relational databases use structured query language (SQL) to store and query data. This approach allows data to be stored in an easily understandable, consistent, and scalable way.</p><h3>Amazon Relational Database Service</h3><p>A service that enables you to run relational databases in the AWS Cloud. Amazon RDS is a managed service that automates tasks such as hardware provisioning, database setup, patching, and backups. Many Amazon RDS database engines offer encryption at rest (protecting data while it is stored) and encryption in transit (protecting data while it is being sent and received). User can restrict access with security group &amp; can plan for backup and recovery strategies. Multi AZ. You can reduce the load on your source DB Instance by routing read queries from your applications to the <em>read replica</em>.</p><p>AWS Multiple Availability Zone deployments allows for AWS to failover to a secondary database in case the primary one fails.</p><h3>Amazon Aurora</h3><p>An enterprise-class relational database. It is faster than standard MySQL and PostgreSQL databases. Amazon Aurora helps to reduce your database costs by reducing unnecessary input/output (I/O) operations, while ensuring that your database resources remain reliable and available. Can auto-scale up to 128 TB.</p><p>Consider Amazon Aurora if your workloads require high availability. It replicates six copies of your data across three Availability Zones and continuously backs up your data to Amazon S3.</p><h3>Nonrelational databases</h3><p>Place to create tables, where you can store and query data. Nonrelational databases are sometimes referred to as “NoSQL databases” because they use structures other than rows and columns to organize data. One type of structural approach is key-value pairs, where data is organized into items (keys), and items have attributes (values).</p><p>In a key-value database, you can add or remove attributes from items in the table at any time. Additionally, not every item in the table has to have the same attributes.</p><h3>Amazon DynamoDB</h3><p>A key-value database service. It delivers single-digit millisecond performance at any scale. Is serverless, so you don’t have to provision, manage, install nor maintain any servers. DynamoDB automatically scales to adjust for changes in capacity while maintaining consistent performance. Dynamo DB chooses Performance over Consistency while delivering reads (“Eventually consistent”).</p><h3>Amazon Redshift</h3><p>A data warehousing service that you can use for big data analytics. It offers the ability to collect data from many sources and helps you to understand relationships and trends across your data. Leader node: Receive queries and manage client connections.</p><h3>AWS Database Migration Service (AWS DMS)</h3><p>Enables you to migrate relational databases, nonrelational databases, and other types of data stores.</p><p>With AWS DMS, you move data between a source database and a target database that can be of the same type or different types. During the migration, your source database remains operational, reducing downtime for any applications that rely on the database. Uses <em>AWS Schema Conversion tool</em> for heterogeneous database migrations where source database &amp; destination database is different.</p><h3>Additional database services</h3><ul><li>DocumentDB: Document database service that supports MongoDB workloads.</li><li>Neptune: A graph database service. You can use Amazon Neptune to build and run applications that work with highly connected datasets</li><li>Quantum Ledger Database (Amazon QLDB): Ledger database service. You can use it to review a complete history of all the changes that have been made to your application data.</li><li>Managed Blockchain: A service that you can use to create and manage blockchain networks with open-source frameworks. Blockchain is a distributed ledger system that lets multiple parties run transactions and share data without a central authority.</li><li>ElastiCache: A service that adds caching layers on top of your databases to help improve the read times of common requests.</li><li>DynamoDB Accelerator: Is an in-memory cache for DynamoDB. It helps improve response times.</li></ul><h3>Other services</h3><p>EMR: is a cloud big data platform for processing vast amounts of data using open-source tools.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2499aca8659a" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/cloud-practitioner-storage-database-2499aca8659a">Cloud Practitioner: Storage &amp; Database</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interview excercise: Replicate .map() with two functions]]></title>
            <link>https://martin-sobrero-m.medium.com/interview-excercise-replicate-map-with-two-functions-23aac869f66f?source=rss-f4de80fd34ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/23aac869f66f</guid>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[code-review]]></category>
            <dc:creator><![CDATA[Martin Sobrero]]></dc:creator>
            <pubDate>Thu, 08 Dec 2022 03:01:21 GMT</pubDate>
            <atom:updated>2022-12-08T03:01:21.586Z</atom:updated>
            <content:encoded><![CDATA[<h3>Interview excercise: Replicate .map() with two functions</h3><p>I recently had a technical interview for a Senior position were I had to code, among other things, the function array.map(). In this post we will go through the excercise and how to solve it without going straight to the answer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/277/0*6K9n-e3YE8_aaqJE.png" /></figure><p>If you want to know more about the .map() function, I explained it in the post <a href="https://medium.com/@martin-sobrero-m/map-vs-filter-vs-reduce-e5b7dd3eb2cc">Map vs. Filter vs. Reduce</a>.</p><p>The excercise said that the function could only use two functions:</p><ul><li>first() which returnes the first item of an array.</li><li>rest() which returns all the array but the first item.</li></ul><p>First things first, I coded these two functions as simple and fast as I could, remember that code interviews are time limited and simple code is always much appreciated.</p><pre>const first = (array) =&gt; array[0];<br>const rest = (array) =&gt; {<br>    return array.slice(1);<br>}</pre><p>My next thought was if using a recursive function was a good idea to solve this problem because, as we all know, the map() function iterates over an array and returns an identical copy of it (assuming there is no code inside the callback function of the map()).</p><p>So I wrote the boilerplate of most recursive functions and asked myself which are the final and middle cases.</p><pre>const map = (array) =&gt; {<br>    // Final case<br>    if () {<br>        return X;<br>    }<br><br>    // Middle cases<br>    return X;<br>}</pre><p>The final case was clear, the loop should stop when it reaches the last item of the array and should return this final item which is in the first position because the array received has a single element.</p><p>My next thought was that the map() function has to return an array, so this edge case should return one as well.</p><pre>const first = (array) =&gt; array[0];<br>const rest = (array) =&gt; {<br>    return array.slice(1);<br>}<br><br>const map = (array) =&gt; {<br>    // Final case<br>    if (array.length === 1) {<br>        return [first(array)];<br>    }<br><br>    // Middle cases<br>    return X;<br>}</pre><p>Now the most complicated part of recursive functions, the middle cases. Again, the function has to return an array and also has to call itself so it could be something like this:</p><pre>const map = (array) =&gt; {<br>    if (array.length === 1) {<br>        return [first(array)];<br>    }<br><br>    return map(rest(array));<br>}</pre><p>But we are missing one small detail, this will return an array with only the list item so we need to add the first item to the result.</p><p>The cleanest way to do it is by creating a new array with this first item and to spread the result (more on the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax">Spread operator</a>) of the recursive call.</p><pre>const first = (array) =&gt; array[0];<br>const rest = (array) =&gt; {<br>    return array.slice(1);<br>}<br><br>const map = (array) =&gt; {<br>    if (array.length === 1) {<br>        return [first(array)];<br>    }<br><br>    return [first(array), ...map(rest(array))];<br>}</pre><p>Finally, there is one last case we need to cover, what happens if the function receives an empty array. In this case, the function should return another empty function. For this, we can update the final case with a small validation.</p><pre>const first = (array) =&gt; array[0];<br>const rest = (array) =&gt; {<br>    return array.slice(1);<br>}<br><br>const map = (array) =&gt; {<br>    if (array.length &lt;= 1) {<br>        return first(array) ? [first(array)] : [];<br>    }<br><br>    return [first(array), ...map(rest(array))];<br>}</pre><p>It is time to test it out! For this I used 4 possible arrays including different data types and lenghts.</p><pre>console.log(map([1,2,3,4,5]))<br>console.log(map([&#39;a&#39;,2,&#39;c&#39;,&#39;d&#39;]))<br>console.log(map([1]))<br>console.log(map([]))</pre><p>The results were more than sufficient for the interview but I am sure this small piece of code can be improved so feel free to comment your solutions or improvements.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23aac869f66f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloud Practitioner: Networking]]></title>
            <link>https://awstip.com/cloud-practitioner-networking-21d0fb512811?source=rss-f4de80fd34ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/21d0fb512811</guid>
            <category><![CDATA[certification]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws-cloud-practitioner]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Martin Sobrero]]></dc:creator>
            <pubDate>Mon, 21 Nov 2022 14:14:35 GMT</pubDate>
            <atom:updated>2022-11-25T12:19:53.388Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the fourth module in the series of documents that helped me pass the “Cloud Practitioner” certification. You can find the other modules here:</p><ul><li>Introduction to AWS [<a href="https://martin-sobrero-m.medium.com/cloud-practitioner-introduction-to-aws-1609cceaf163">Link</a>]</li><li>Compute in the cloud [<a href="https://awstip.com/cloud-practitioner-compute-in-the-cloud-3f5c94576b67">Link</a>]</li><li>Global infrastructure and reliability [<a href="https://martin-sobrero-m.medium.com/cloud-practitioner-global-infrastructure-and-reliability-22b3ba3249be">Link</a>]</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*M4YfPAiXu3dGQPQB.png" /></figure><h3>Amazon Virtual Private Cloud (Amazon VPC)</h3><p>A free networking service that you can use to establish boundaries around your AWS resources.</p><p>Amazon VPC enables you to provision an isolated section of the AWS Cloud. In this isolated section, you can launch resources in a virtual network that you define. Within a VPC, you can organize your resources into subnets. A subnet is a section of a VPC that can contain resources such as Amazon EC2 instances.</p><p>Internet gateway: To allow public traffic from the internet to access your VPC. Is a connection between a VPC and the internet. Without an internet gateway, no one can access the resources within your VPC.</p><h3>Virtual private gateway</h3><p>To access private resources in a VPC, you can use a virtual private gateway. Is the component that allows protected internet traffic to enter the VPC.</p><p>Virtual private network (VPN): Connection that encrypts (or protects) your internet traffic from all the other requests around it. Full hour is billed.</p><p>A virtual private gateway enables you to establish a virtual private network (VPN) connection between your VPC and a private network, such as an on-premises data center or internal corporate network. A virtual private gateway allows traffic into the VPC only if it is coming from an approved network.</p><p>Network address translation (NAT) gateway: To enable instances in a private subnet to connect to the internet or other AWS services, but prevent the internet from initiating a connection with those instances.</p><h3>AWS Direct Connect</h3><p>AWS Direct Connect is a service that enables you to establish a dedicated private connection between your data center and a VPC.</p><p>The private connection that AWS Direct Connect provides helps you to reduce network costs and increase the amount of bandwidth that can travel through your network. AWS Direct Connect supports only the BGP (Border Gateway Protocol) routing protocol for this connectivity.</p><h3>Subnets</h3><p>A section of a VPC in which you can group resources based on security or operational needs. Subnets can be public or private. In a VPC, subnets can communicate with each other.</p><p>Public subnets contain resources that need to be accessible by the public, such as an online store’s website.</p><p>Private subnets contain resources that should be accessible only through your private network, such as a database that contains customers’ personal information and order histories.</p><h3>Network traffic in a VPC</h3><p>A packet is a unit of data sent over the internet or a network, which is sent as request to an application hosted in the AWS Cloud. It enters a VPC through an internet gateway. Before a packet can enter a subnet or exit one, it checks for permissions. These permissions indicate who sent the packet and how the packet is trying to communicate with the resources in a subnet.</p><p>The VPC component that checks packet permissions for subnets is a network access control list (ACL). VPC endpoint configured by AWS Private Link can have Amazon SES (Simple Email Service).</p><h3>Network access control lists (NACLs)</h3><p>An optional virtual firewall that controls inbound and outbound traffic at the subnet level. Each AWS account includes a default network ACL. When configuring your VPC, you can use your account’s default network ACL or create custom network ACLs.</p><p>By default, your account’s default network ACL allows all inbound and outbound traffic, but you can modify it. For custom network ACLs, all inbound and outbound traffic is denied until you add rules to specify which traffic to allow. Additionally, all network ACLs have an explicit deny rule. This rule ensures that if a packet doesn’t match any of the other rules on the list, the packet is denied.</p><h3>Stateless packet filtering</h3><p>Network ACLs perform stateless packet filtering. They remember nothing and check packets that cross the subnet border each way: inbound and outbound. The VPC component that checks packet permissions for an Amazon EC2 instance is a security group.</p><h4>Security groups</h4><p>A security group is a virtual firewall that controls inbound and outbound traffic for an Amazon EC2 instance. By default, a security group denies all inbound traffic and allows all outbound traffic. You can add custom rules to configure which traffic to allow or deny. Instance level.</p><p>If you have multiple instances within a subnet, you can associate them with the same security group.</p><h3>Stateful packet filtering</h3><p>Security groups perform stateful packet filtering. They remember previous decisions made for incoming packets. Both network ACLs and security groups enable you to configure custom rules for the traffic in your VPC.</p><p>NameDefinitionPrivate subnetIsolates databases containing customers personal informationVirtual private gatewayCreate a VPN connection between VPC and the internal corporate networkPublic subnetSupport the customer facing websiteAWS Direct connectEstablish a dedicated connection between the on-premises data center and the VPCSecurity groupsThey are stateless and deny all inbound traffic by default.</p><h3>Domain Name System (DNS)</h3><p>Customers enter a web address into their browser, and they can access the website. This happens because of Domain Name System (DNS) resolution. DNS resolution involves a DNS server communicating with a web server.</p><h3>Amazon Route 53</h3><p>Amazon Route 53 is a DNS web service. It gives developers and businesses a reliable way to route end users to internet applications hosted in AWS. Amazon Route 53 connects user requests to infrastructure running in AWS. It can route users to infrastructure outside of AWS.</p><p>Another feature of Route 53 is the ability to manage the DNS records for domain names. You can register new domain names directly in Route 53. You can also transfer DNS records for existing domain names managed by other domain registrars. This enables you to manage all your domain names within a single location.</p><p>It takes 24 to 48 hours to update resolvers around the world because those can only reflect their changes in their cache after the Time to Live has expired.</p><p>The geolocation policy allows for different resources to serve content based on the origin of the request.</p><ul><li>Multivalue routing: Returns multiple healthy IP addresses. Improves availability and load balancing.</li><li>Failover routing: When 99.99% of uptime is required. Used in disaster recovery scenarios.</li><li>Weighted routing: Route traffic in proportions.</li></ul><p>VPC peering connection is a networking connection between two VPCs that enables you to route traffic between them using private IPv4 addresses or IPv6 addresses. Instances in either VPC can communicate with each other as if they are within the same network. You can create a VPC peering connection between your own VPCs, or with a VPC in another AWS account. The VPCs can be in different regions (also known as an inter-region VPC peering connection). <em>Fault-Tolerance, disaster recovery and redundancy</em>.</p><h3>Other services</h3><p>Elastic IP: Static IP address that can be created and assigned to an AWS Account rather than to an Availability Zone.</p><p>EventBridge: is a serverless event bus that makes it easy to connect applications together using data from your own applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21d0fb512811" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/cloud-practitioner-networking-21d0fb512811">Cloud Practitioner: Networking</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS: How to upload to an encrypted S3 in a different account]]></title>
            <link>https://awstip.com/aws-how-to-upload-to-an-encrypted-s3-in-a-different-account-11e2bc37a966?source=rss-f4de80fd34ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/11e2bc37a966</guid>
            <category><![CDATA[km]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws-s3]]></category>
            <dc:creator><![CDATA[Martin Sobrero]]></dc:creator>
            <pubDate>Thu, 10 Nov 2022 23:22:13 GMT</pubDate>
            <atom:updated>2022-11-18T17:43:29.286Z</atom:updated>
            <content:encoded><![CDATA[<p>Uploading a file to a S3 bucket is a very common functionality that many of us implemented. In some cases the easiest (and best) option is to generate a presigned URL (check this other post for more information: <a href="https://medium.com/aws-tip/aws-what-are-presigned-urls-b6d2ab952f1c">What are presigned URLs</a>).</p><p>In other cases we have to upload the object using cross account configurations, this means putting the object from an AWS account to a different one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*pzWfZkYIZgWDtLSAeadezQ.png" /></figure><p>Let’s imagine we have accountA and accountB, now first we need to ensure that accountA allows accountB to upload objects. For this, we add this policy to the bucket role in accountA.</p><pre>{<br>  &quot;Sid&quot;: &quot;CrossAccBkt&quot;,<br>  &quot;Action&quot;: [<br>    &quot;s3:GetObject&quot;,<br>    &quot;s3:PutObject&quot;,<br>    &quot;s3:ListObject&quot;<br>  ],<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Resource&quot;: &quot;arn:aws:s3:::&lt;name-of-bucket&gt;/*&quot;,<br>  &quot;Principal&quot;: {<br>    &quot;AWS&quot;: [<br>      &quot;arn:aws:iam::&lt;account-id&gt;:root&quot;<br>    ]<br>  }<br>}</pre><p>Where:</p><ul><li>Action array items are each of the permissions we are adding for the user (for this example we only need ’GetObject’)</li><li>Resource is the ARN of the bucket. Dont forget to add “/*” to allow all the inside of the bucket.</li><li>Principal the ARN of the user we are allowing. In this case accountB.</li></ul><p>Now we need to allow accountB to use the KMS key declared in accountA for encrypting and decrypting the objects. For this, we add this policy to the KMS role in accountA.</p><pre>{<br>  &quot;Sid&quot;: &quot;CrossAccKms&quot;,<br>  &quot;Effect&quot;: &quot;Allow&quot;,<br>  &quot;Principal&quot;: {<br>    &quot;AWS&quot;: [<br>      &quot;arn:aws:iam::&lt;account-id&gt;:role/&lt;role-name&gt;&quot;<br>    ]<br>  },<br>  &quot;Action&quot;: [<br>    &quot;kms:Decrypt&quot;<br>  ],<br>  &quot;Resource&quot;: &quot;*&quot;<br>}</pre><p>After that, we need to go the accountB and add the policies for accessing the bucket and for using the KMS key.</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>        &quot;Sid&quot;: &quot;CrossAccBkt&quot;,<br>        &quot;Action&quot;: [<br>            &quot;s3:GetObject&quot;<br>        ],<br>        &quot;Effect&quot;: &quot;Allow&quot;,<br>        &quot;Resource&quot;: &quot;arn:aws:s3:::&lt;name-of-bucket&gt;/*&quot;<br>    },<br>    {<br>        &quot;Sid&quot;: &quot;CrossAccKms&quot;,<br>        &quot;Action&quot;: [<br>            &quot;kms:Decrypt&quot;<br>        ],<br>        &quot;Effect&quot;: &quot;Allow&quot;,<br>        &quot;Resource&quot;: &quot;arn:aws:kms:&lt;region&gt;:&lt;account-id&gt;:key/&lt;key-id-hash&gt;&quot;<br>    }<br>  ]<br>}</pre><p>Where:</p><ul><li>Action array items are each of the permissions we are adding for the user. One policy for the bucket and one for the KMS decrypt.</li><li>Resource will be the ARN of the resource. In one policy the ARN of the bucket and in the other the ARN of the managed key. In this case, the account ID will be the one from accountA.</li></ul><p>With that should be enough to be able to send the object the the other account. The code in NodeJs should look something like this:</p><pre>let s3 = new AWS.S3({ apiVersion: &#39;2006-03-01&#39;, region: &lt;AWS_REGION&gt; });<br><br>const params = {<br>  Bucket: &#39;&lt;name-of-bucket&gt;&#39;,<br>  Key: &#39;file.csv&#39;,<br>  Body: csv,<br>  ContentType: &#39;text/csv&#39;,<br>  ServerSideEncryption: &#39;aws:kms&#39; // Dont forget for the KMS encryption<br>};<br>const result = await s3.putObject(params).promise();</pre><p>And thats it 😁! Now we can upload a file to a cross account S3 bucket that is encrypted using KMS.</p><h3>Access denied when using the uploaded file</h3><p>If you find the error “Access denied” when trying to download or open the uploaded file, verify the ownership of the object.</p><p>This is because when uploading an object, its owner is still the account that uploaded it, make it unusable for the receiver account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WPoJH5vKcRvYJwSFKB_URA.png" /><figcaption>View from the Aws Console</figcaption></figure><p>If you want to do it using Cloudformation:</p><pre>Type: AWS::S3::Bucket<br>Properties: <br>  ...<br>  OwnershipControls: <br>    Rules:<br>     - ObjectOwnership: BucketOwnerEnforced</pre><h3>More info</h3><ul><li><a href="https://aws.amazon.com/premiumsupport/knowledge-center/cross-account-access-denied-error-s3/">Why are cross-account users getting Access Denied errors when they try to access S3 objects encrypted by a custom AWS KMS key?</a></li><li>S3: <a href="https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putObject-property">putObject</a></li><li><a href="https://stackoverflow.com/questions/65226175/kms-not-found-exception-in-aws-cross-account-s3-putobject-encrypted-by-aws-manag">KMS Not found Exception in AWS Cross Account S3 PutObject encrypted by AWS Managed Key</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11e2bc37a966" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/aws-how-to-upload-to-an-encrypted-s3-in-a-different-account-11e2bc37a966">AWS: How to upload to an encrypted S3 in a different account</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cookies vs Session storage vs Local storage]]></title>
            <link>https://martin-sobrero-m.medium.com/cookies-vs-session-storage-vs-local-storage-c63e49d1e064?source=rss-f4de80fd34ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/c63e49d1e064</guid>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[cookies]]></category>
            <category><![CDATA[storage]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Martin Sobrero]]></dc:creator>
            <pubDate>Sat, 29 Oct 2022 22:50:08 GMT</pubDate>
            <atom:updated>2022-12-20T17:59:55.017Z</atom:updated>
            <content:encoded><![CDATA[<p>Many of us talk about this user side storage options but usually we don’t know the differences. So in this document we will try to clarify one of the most common frontend interview questions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*zVODUH3A_bj8wJoU1S83Fw.png" /></figure><p>We all know that all three options are client side solutions for storing data in the browser as plain text (you can store more complex data structures like objects but you need to handle the parsing first), but not all options store that data for the same duration.</p><p>As the data is stored in plain text, these are not good solutions for storing sensitive data which can be easily accesed and modified by the user.</p><p>Also, as the data can be modified by the user, this storage options cannot be completely trusted as the user may remove them. It is the application responsiblity to handle the possibility that the values are not there any more.</p><p>Both sessionStorage and localStorage are kind of new APIs (introduced with HTML 5) while cookies have been arround since HTML 4.</p><h3>Cookies</h3><p>Cookies are the best way of storing the user’s authentication data because are sent to the backend and then to the frontend again with each request, meaning that both sides can be sure of the users identity.</p><p>On the other hand, that the cookies are sent to the backend and back to the frontend means that they could be intercepted. It is not very common due to the use of SSL certificates but it is something to keep in mind.</p><p>Finally, the addition of the cookies to each request and response may make them a big heavier and slower than we want them to be, so we should keep only the necessary data.</p><h3>Session and Local storage</h3><p>Both sessionStorage and localStorage are identical, not only in how they are used and what they offer. They both store the data in the form of key/value pairs on the client side and can be accesed and modified from the browser’s terminal.</p><p>The most important difference between the two is the persistence duration:</p><ul><li>Session storage lasts the same as the session, so if you close the tab or the browser it is removed. It does survive page reloads.</li><li>Local storage never expires, they will last until the application or the user manually removes them.</li></ul><p>The way to set a key-value item is:</p><pre>sessionStorage.setItem(&quot;key&quot;, &quot;value&quot;);<br>localStorage.setItem(&quot;key&quot;, &quot;value&quot;);</pre><p>The way to get the value of an item is:</p><pre>let data = sessionStorage.getItem(&quot;key&quot;);<br>let data = localStorage.getItem(&quot;key&quot;);</pre><p>And finally to remove or clear the storage:</p><pre>sessionStorage.removeItem(&quot;key&quot;);<br>localStorage.removeItem(&quot;key&quot;);<br><br>sessionStorage.clear();<br>localStorage.clear();</pre><h3>Conclusion</h3><p>All three options are valid and good choices depending on the use case. The best way of identifying which one to use is to check for how long do you need that data and if you also need to use it in the backend.</p><p>Also, you may need to consider if storing data locally in the browser is a good decision as sometimes is more secure and controllable to store the data in a simple and fast database in the backend.</p><h3>Other links</h3><ul><li><a href="https://www.xenonstack.com/insights/local-vs-session-storage-vs-cookie">Xenonstack</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage">Local storage</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage">Session storage</a></li><li><a href="https://stackoverflow.com/questions/19867599/what-is-the-difference-between-localstorage-sessionstorage-session-and-cookies">What is the difference between localStorage, sessionStorage, session and cookies?</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c63e49d1e064" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS: What are presigned URLs]]></title>
            <link>https://awstip.com/aws-what-are-presigned-urls-b6d2ab952f1c?source=rss-f4de80fd34ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6d2ab952f1c</guid>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws-cloudformation]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-s3]]></category>
            <dc:creator><![CDATA[Martin Sobrero]]></dc:creator>
            <pubDate>Sun, 02 Oct 2022 23:52:10 GMT</pubDate>
            <atom:updated>2022-12-20T18:00:55.242Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post we will talk about the presigned URLs that we can generate for managing objects inside an AWS S3 bucket. We will cover topics like what are these URLs for, who can generate them and how do we use them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*pzWfZkYIZgWDtLSAeadezQ.png" /></figure><h3>What are presigned URLs for</h3><p>All buckets are private by default and even though you can make them public, doing it is not recommended for security reasons. So, how do you upload a file from directly from the web application without passing through a Lambda function? The answer is to generate a presigned URL for the frontend to use.</p><p>These presigned URLs will have the permission to perform a certain action (put an object, get an object) for a period of time after which the URL will be invalid.</p><p>Both these options (the action and the duration which tops at 7 days) are configurable when creating the presigned URL.</p><h3>Who can create a presigned URL</h3><p>A presigned URL can be created by any user who has the necessary access to the bucket and the object.</p><p>This is, if a user has access to create objects then will be able to create a presigned URL for putting objects inside the bucket. But if the user only has access to view objects (not creating them), then will not be able to create a presigned URL for putting a new object.</p><h3>Code</h3><p>Now that we know what presigned URLs are and what are they used for, lets code a simple example. The idea is to simulate a web app that wants to upload a file to the S3 bucket so we will need a Lambda function to generate the presigned URLs for the frontend, and then the frontend will do the request to upload.</p><p>For the example we will use the code from the previous post “<a href="https://awstip.com/create-an-api-with-aws-sam-5822e8d6f028">Create an API with AWS &amp; SAM</a>” as template.</p><p>First, let’s go with the Lambda function. We’ll need to import some constants, for let’s install the dependencies.</p><pre>npm i @aws-sdk/s3-request-presigner --save<br>npm i @aws-sdk/client-s3 --save</pre><p>Now we add all the necessary code to the Lambda, including:</p><ul><li>new S3Client is where we define the region and the version.</li><li>new PutObjectCommand is the command which indicates that we are going to put a new object in the S3. If we wanted to get an object we would use GetObjectCommand. These commands define the name of the bucket and the name (Key) of the file.</li><li>await getSignedUrl where we define the client, the command and the properties of the presigned URL, for example the duration in seconds.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/253a08a0c72414bbfed6c08468c53208/href">https://medium.com/media/253a08a0c72414bbfed6c08468c53208/href</a></iframe><p>Before testing the code we need to add one more variable which is the name of the bucket BUCKET_NAME . A good practice is to have is as an environment variable in the template.yaml where the bucket is created.</p><pre><strong>SimpleBucket</strong>:<br>  Type: &quot;AWS::S3::Bucket&quot;<br>  ...</pre><pre>SimpleLamdbaFunction:<br>  Type: AWS::Serverless::Function<br>  DependsOn:<br>    - LambdaRole<br>  Properties:<br>    Handler: app.handler<br>    CodeUri: ./simple-log<br>    Runtime: nodejs16.x<br>    Environment:<br>      Variables:<br>        BUCKET_NAME:<br>          Ref: <strong>SimpleBucket</strong><br>    ...</pre><p>Now it is time to test it:</p><ul><li>Build and deploy the changes using sam build ; sam deploy.</li><li>Get the URL of the lambda in the Dashboard view of the API Gateway in the AWS Console.</li><li>Create a POST request using Postman or similar. The response should be an object with two properties: response and url .</li><li>Create a new PUT request for this new URL. In the body select “binary” and upload the .txt file of choice.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*h-SenC6hs8TX-8R3Q2kzbA.png" /></figure><ul><li>Send the request. If it is a success, check the S3 Bucket to which you uploaded the file. It should contain the new file with the name we defined in the PutObjectCommand .</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*lDPBjLZdwEw3Touj1t6FFQ.png" /></figure><p>And that is it! Now we have a fast and simple way for the web application to upload a file to the bucket.</p><h3>More info</h3><ul><li><a href="https://awstip.com/create-an-api-with-aws-sam-5822e8d6f028">Create an API with AWS &amp; SAM</a></li><li><a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/using-presigned-url.html">Using presigned URLs</a></li><li><a href="https://aws.amazon.com/blogs/developer/generate-presigned-url-modular-aws-sdk-javascript/">Generate a presigned URL in modular AWS SDK for JavaScript</a></li><li><a href="https://www.npmjs.com/package/@aws-sdk/client-s3">@aws-sdk/client-s3</a></li><li><a href="https://www.npmjs.com/package/@aws-sdk/s3-request-presigner">@aws-sdk/s3-request-presigner</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6d2ab952f1c" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/aws-what-are-presigned-urls-b6d2ab952f1c">AWS: What are presigned URLs</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloud Practitioner: Global infrastructure and reliability]]></title>
            <link>https://martin-sobrero-m.medium.com/cloud-practitioner-global-infrastructure-and-reliability-22b3ba3249be?source=rss-f4de80fd34ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/22b3ba3249be</guid>
            <category><![CDATA[certification]]></category>
            <category><![CDATA[cloud-practitioner]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-cloud-practitioner]]></category>
            <dc:creator><![CDATA[Martin Sobrero]]></dc:creator>
            <pubDate>Fri, 12 Aug 2022 13:25:05 GMT</pubDate>
            <atom:updated>2022-08-12T13:25:05.314Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the third module in the series of documents that helped me pass the “Cloud Practitioner” certification. You can find the other modules here:</p><ul><li>Introduction to AWS [<a href="https://martin-sobrero-m.medium.com/cloud-practitioner-introduction-to-aws-1609cceaf163">Link</a>]</li><li>Compute in the cloud [<a href="https://awstip.com/cloud-practitioner-compute-in-the-cloud-3f5c94576b67">Link</a>]</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*0HhU8rqWZwWvGlDB.png" /></figure><h3>Selecting a Region</h3><ul><li><strong>Compliance with data governance and legal requirements:</strong> Depending on your company and location, you might need to run your data out of specific areas.</li><li><strong>Proximity to your customers:</strong> Selecting a Region that is close to your customers will help you to get content to them faster.</li><li><strong>Available services within a Region:</strong> The closest Region might not have all the features that you want to offer to customers.</li><li><strong>Pricing:</strong> May change based on local taxes or other factors.</li></ul><h3>Availability zone</h3><p>Single data center or a group of data centers within a Region. Availability Zones are located tens of miles apart from each other. This is close enough to have low latency (the time between when content requested and received) between Availability Zones. Regions are completely isolated.</p><h3>Edge locations</h3><p>Site that Amazon CloudFront (a global content delivery service, that cache dynamic content and can’t use S3 buckets as their origin server) uses to store cached copies of your content closer to your customers for faster delivery.</p><h3>Ways to interact with AWS services</h3><p><strong>AWS Outposts: </strong>Extend AWS infrastructure and services to your on-premises data center. Service that provides hybrid experience by facilitating running AWS services and infrastructure on premises.</p><h3>AWS management console</h3><p>Web-based interface for accessing and managing AWS services. The console includes wizards and automated workflows that can simplify the process of completing tasks. A web-based user interface that helps users to access and manage aspects of AWS services.</p><p>You can also use the AWS Console mobile application to perform tasks such as monitoring resources, viewing alarms, and accessing billing information. Multiple identities can stay logged into the AWS Console mobile app at the same time.</p><h3>AWS command line interface</h3><p>Enables you to control multiple AWS services directly from the command line within one tool. AWS CLI is available for users on Windows, macOS, and Linux.</p><p>By using AWS CLI, you can automate the actions that your services and applications perform through scripts. Also, SSH allows users to interact with AWS services through AWS CLI.</p><h3>Software development kits</h3><p>SDKs make it easier for you to use AWS services through an API designed for your programming language or platform. SDKs enable you to use AWS services with your existing applications or create entirely new applications that will run on AWS.</p><h3>AWS Elastic Beanstalk</h3><p>You provide code and configuration settings, and Elastic Beanstalk deploys the resources necessary to perform the following tasks: Adjust capacity, Load balancing, Automatic scaling, Application health monitoring. A service for deploying and scaling web applications and services. For deploying and scaling webapps.</p><h3>AWS CloudFormation</h3><p>You can treat your infrastructure as code. This means that you can build an environment by writing lines of code. AWS CloudFormation provisions your resources in a safe, repeatable manner, enabling you to frequently build your infrastructure and applications without having to perform manual actions or write custom scripts.</p><h3>Other Services</h3><p><strong>Global accelerator: </strong>Improves performance and availability. It doesn’t include content caching capability and is for apps that are not HTTP.</p><p><strong>Resource access manager:</strong> Allows to share resources between multiple AWS accounts.</p><p><strong>Service Catalog: </strong>Ideal for organizing, distributing, and provisioning application stacks on AWS. Uses AWS IAM &amp; AWS CloudFormation to create a portfolio of products.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22b3ba3249be" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>