<?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"><channel><title><![CDATA[crunchcrunch]]></title><description><![CDATA[crunchcrunch]]></description><link>https://crunchcrunch.me</link><generator>RSS for Node</generator><lastBuildDate>Mon, 18 May 2026 05:42:10 GMT</lastBuildDate><atom:link href="https://crunchcrunch.me/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Deploying AWS Bedrock AgentCore Agents with Pulumi]]></title><description><![CDATA[AWS Bedrock AgentCore lets you deploy agents as managed containerized runtimes.
This guide shows how to automate this deployment using Pulumi and Docker.
What You'll Deploy

Docker container with your agent code

Amazon ECR to store the image

Bedroc...]]></description><link>https://crunchcrunch.me/deploying-aws-bedrock-agentcore-agents-with-pulumi</link><guid isPermaLink="true">https://crunchcrunch.me/deploying-aws-bedrock-agentcore-agents-with-pulumi</guid><category><![CDATA[AWS]]></category><category><![CDATA[bedrock]]></category><category><![CDATA[bedrock agentcore]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Fri, 05 Dec 2025 14:46:23 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/WhAQMsdRKMI/upload/8bed4e5e8e041ad5369a09742e1b96a3.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>AWS Bedrock AgentCore lets you deploy agents as managed containerized runtimes.</p>
<p>This guide shows how to automate this deployment using Pulumi and Docker.</p>
<h3 id="heading-what-youll-deploy">What You'll Deploy</h3>
<ul>
<li><p>Docker container with your agent code</p>
</li>
<li><p>Amazon ECR to store the image</p>
</li>
<li><p>Bedrock AgentCore Runtime to run your agent</p>
</li>
</ul>
<h3 id="heading-the-setup">The Setup</h3>
<ol>
<li>Your Agent Code</li>
</ol>
<pre><code class="lang-python"><span class="hljs-comment"># agents/my_agent/api.py</span>
<span class="hljs-keyword">from</span> fastapi <span class="hljs-keyword">import</span> FastAPI
<span class="hljs-keyword">from</span> langchain_openai <span class="hljs-keyword">import</span> ChatOpenAI
<span class="hljs-keyword">import</span> uvicorn

app = FastAPI()

<span class="hljs-meta">@app.post("/invoke")</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">invoke</span>(<span class="hljs-params">input_data: dict</span>):</span>
    llm = ChatOpenAI(model=<span class="hljs-string">"gpt-4"</span>)
    response = llm.invoke(input_data[<span class="hljs-string">"input"</span>])
    <span class="hljs-keyword">return</span> {<span class="hljs-string">"output"</span>: response.content}

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
    uvicorn.run(app, host=<span class="hljs-string">"0.0.0.0"</span>, port=<span class="hljs-number">8080</span>)
</code></pre>
<ol start="2">
<li>Test Locally</li>
</ol>
<pre><code class="lang-yaml"><span class="hljs-comment"># Set your OpenAI API key</span>
<span class="hljs-string">export</span> <span class="hljs-string">OPENAI_API_KEY="sk-..."</span>

<span class="hljs-comment"># Run the agent</span>
<span class="hljs-string">python</span> <span class="hljs-string">agents/my_agent/api.py</span>
</code></pre>
<p>Test with curl:</p>
<pre><code class="lang-yaml"><span class="hljs-string">curl</span> <span class="hljs-string">-X</span> <span class="hljs-string">POST</span> <span class="hljs-string">http://localhost:8080/invoke</span> <span class="hljs-string">\</span>
  <span class="hljs-string">-H</span> <span class="hljs-string">"Content-Type: application/json"</span> <span class="hljs-string">\</span>
  <span class="hljs-string">-d</span> <span class="hljs-string">'{"input": "Hello, what is AI?"}'</span>
</code></pre>
<p>Example response:</p>
<pre><code class="lang-yaml">{
  <span class="hljs-attr">"output":</span> <span class="hljs-string">"AI, or Artificial Intelligence, refers to..."</span>
}
</code></pre>
<ol start="3">
<li>Dockerfile</li>
</ol>
<pre><code class="lang-dockerfile"><span class="hljs-keyword">FROM</span> --platform=linux/arm64 ghcr.io/astral-sh/uv:python3.<span class="hljs-number">13</span>-bookworm-slim

<span class="hljs-keyword">WORKDIR</span><span class="bash"> /app</span>

<span class="hljs-comment"># Copy dependencies</span>
<span class="hljs-keyword">COPY</span><span class="bash"> pyproject.toml uv.lock</span>
<span class="hljs-keyword">COPY</span><span class="bash"> agents ./agents</span>

<span class="hljs-comment"># Install dependencies</span>
<span class="hljs-keyword">RUN</span><span class="bash"> uv sync --frozen --no-cache</span>

<span class="hljs-keyword">EXPOSE</span> <span class="hljs-number">8080</span>

<span class="hljs-comment"># Start the agent API</span>
<span class="hljs-keyword">CMD</span><span class="bash"> uv run uvicorn agents.my_agent.api:app --host 0.0.0.0 --port 8080</span>
</code></pre>
<ol start="4">
<li>Build and Push</li>
</ol>
<pre><code class="lang-yaml"><span class="hljs-comment"># Login to ECR</span>
<span class="hljs-string">aws</span> <span class="hljs-string">ecr</span> <span class="hljs-string">get-login-password</span> <span class="hljs-string">--region</span> <span class="hljs-string">eu-west-1</span> <span class="hljs-string">|</span> <span class="hljs-string">\</span>
  <span class="hljs-string">docker</span> <span class="hljs-string">login</span> <span class="hljs-string">--username</span> <span class="hljs-string">AWS</span> <span class="hljs-string">--password-stdin</span> <span class="hljs-string">&lt;account&gt;.dkr.ecr.eu-west-1.amazonaws.com</span>

<span class="hljs-comment"># Build for ARM64</span>
<span class="hljs-string">docker</span> <span class="hljs-string">buildx</span> <span class="hljs-string">build</span> <span class="hljs-string">\</span>
  <span class="hljs-string">--platform</span> <span class="hljs-string">linux/arm64</span> <span class="hljs-string">\</span>
  <span class="hljs-string">-t</span> <span class="hljs-string">&lt;account&gt;.dkr.ecr.eu-west-1.amazonaws.com/my-agents:my_agent_v1</span> <span class="hljs-string">\</span>
  <span class="hljs-string">--load</span> <span class="hljs-string">\</span>
  <span class="hljs-string">.</span>

<span class="hljs-comment"># Push to ECR</span>
<span class="hljs-string">docker</span> <span class="hljs-string">push</span> <span class="hljs-string">&lt;account&gt;.dkr.ecr.eu-west-1.amazonaws.com/my-agents:my_agent_v1</span>
</code></pre>
<ol start="5">
<li>Deploy with Pulumi</li>
</ol>
<pre><code class="lang-python"><span class="hljs-comment"># __main__.py</span>
<span class="hljs-keyword">import</span> pulumi
<span class="hljs-keyword">import</span> pulumi_aws <span class="hljs-keyword">as</span> aws

<span class="hljs-comment"># Load config</span>
config = pulumi.Config()
region = config.require(<span class="hljs-string">"aws_region"</span>)
bedrock_role_arn = config.require(<span class="hljs-string">"bedrock_role_arn"</span>)

<span class="hljs-comment"># Get existing ECR repository</span>
ecr_repo = aws.ecr.get_repository(name=<span class="hljs-string">"my-agents"</span>)

<span class="hljs-comment"># Build image URI</span>
image_uri = <span class="hljs-string">f"<span class="hljs-subst">{ecr_repo.repository_url}</span>:my_agent_v1"</span>

<span class="hljs-comment"># Deploy to Bedrock AgentCore</span>
runtime = aws.bedrock.AgentcoreAgentRuntime(
    <span class="hljs-string">"my_agent_runtime"</span>,
    agent_runtime_name=<span class="hljs-string">"my_agent"</span>,
    agent_runtime_artifact={
        <span class="hljs-string">"artifact_type"</span>: <span class="hljs-string">"Docker"</span>,
        <span class="hljs-string">"docker_uri"</span>: image_uri,
    },
    role_arn=bedrock_role_arn,
    environment_variables=[
        {<span class="hljs-string">"name"</span>: <span class="hljs-string">"AWS_REGION"</span>, <span class="hljs-string">"value"</span>: region},
        {<span class="hljs-string">"name"</span>: <span class="hljs-string">"ENV"</span>, <span class="hljs-string">"value"</span>: <span class="hljs-string">"production"</span>},
    ],
)

<span class="hljs-comment"># Export outputs</span>
pulumi.export(<span class="hljs-string">"runtime_name"</span>, runtime.agent_runtime_name)
pulumi.export(<span class="hljs-string">"runtime_arn"</span>, runtime.arn)
</code></pre>
<ol start="6">
<li>Configure and Deploy</li>
</ol>
<pre><code class="lang-yaml"><span class="hljs-comment"># Set configuration</span>
<span class="hljs-string">pulumi</span> <span class="hljs-string">config</span> <span class="hljs-string">set</span> <span class="hljs-string">aws:region</span> <span class="hljs-string">eu-west-1</span>
<span class="hljs-string">pulumi</span> <span class="hljs-string">config</span> <span class="hljs-string">set</span> <span class="hljs-string">aws_region</span> <span class="hljs-string">eu-west-1</span>
<span class="hljs-string">pulumi</span> <span class="hljs-string">config</span> <span class="hljs-string">set</span> <span class="hljs-string">bedrock_role_arn</span> <span class="hljs-string">arn:aws:iam::123456:role/AmazonBedrockExecutionRoleForAgents</span>

<span class="hljs-comment"># Deploy</span>
<span class="hljs-string">pulumi</span> <span class="hljs-string">up</span>
</code></pre>
<h3 id="heading-important-notes">Important Notes</h3>
<p>ARM64 Required: Bedrock AgentCore only supports ARM64 architecture.</p>
<p>Always use <code>--platform linux/arm64</code>.</p>
<p>Runtime Naming Rules:</p>
<ul>
<li><p>Must start with a letter</p>
</li>
<li><p>Only alphanumeric characters and underscores</p>
</li>
<li><p>Max 48 characters</p>
</li>
</ul>
<p>IAM Role Permissions:</p>
<p>The Bedrock role needs:</p>
<ul>
<li><p>ecr:GetAuthorizationToken</p>
</li>
<li><p>ecr:BatchGetImage</p>
</li>
<li><p>logs:CreateLogGroup, logs:CreateLogStream, logs:PutLogEvents</p>
</li>
</ul>
<h3 id="heading-viewing-your-agent">Viewing Your Agent</h3>
<ol>
<li><p>Go to AWS Console → Amazon Bedrock AgentCore</p>
</li>
<li><p>Navigate to Agent runtime</p>
</li>
<li><p>Find your runtime in the list</p>
</li>
<li><p>Choose Test endpoint to interact with it</p>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[Deploying AWS Bedrock Agents with Pulumi]]></title><description><![CDATA[Introduction
This guide shows how to deploy AWS Bedrock Agents using Pulumi and TypeScript.
Prerequisites

AWS Account with Bedrock access

Node.js and npm installed

Pulumi CLI installed


Project Setup

Generate Project with Pulumi pulumi new aws-t...]]></description><link>https://crunchcrunch.me/deploying-aws-bedrock-agents-with-pulumi</link><guid isPermaLink="true">https://crunchcrunch.me/deploying-aws-bedrock-agents-with-pulumi</guid><category><![CDATA[AWS]]></category><category><![CDATA[bedrock]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Mon, 20 Oct 2025 16:45:26 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/jt7evh3U72I/upload/0f6740fd5d97770ccbf10e0cbaf24df6.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>This guide shows how to deploy AWS Bedrock Agents using Pulumi and TypeScript.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<ul>
<li><p>AWS Account with Bedrock access</p>
</li>
<li><p>Node.js and npm installed</p>
</li>
<li><p>Pulumi CLI installed</p>
</li>
</ul>
<h2 id="heading-project-setup">Project Setup</h2>
<ol>
<li>Generate Project with Pulumi<br /> <code>pulumi new aws-typescript</code><br /> <code>cd bedrock-agent-project</code></li>
</ol>
<p>This creates a complete TypeScript project with:</p>
<ul>
<li><p>package.json with all dependencies</p>
</li>
<li><p>Pulumi.yaml configuration</p>
</li>
<li><p>index.ts entry point</p>
</li>
<li><p>TypeScript configuration</p>
</li>
</ul>
<ol start="2">
<li><p>Project Structure</p>
<pre><code class="lang-bash"> bedrock-agent-project/
 ├── package.json
 ├── Pulumi.yaml
 ├── index.ts
 ├── tsconfig.json
 └── agent/
 ├── agent-deploy.ts
 └── instructions.txt
</code></pre>
</li>
</ol>
<h2 id="heading-pulumi-configuration">Pulumi Configuration</h2>
<p>Complete the file Pulumi.yaml with the following content:</p>
<pre><code class="lang-yaml"><span class="hljs-attr">name:</span> <span class="hljs-string">My</span> <span class="hljs-string">first</span> <span class="hljs-string">agent</span>
<span class="hljs-attr">description:</span> <span class="hljs-string">"Stack used to deploy my agent"</span>
<span class="hljs-attr">config:</span>
<span class="hljs-attr">aws_region:</span> <span class="hljs-string">us-east-1</span>
<span class="hljs-attr">aws_accountId:</span> <span class="hljs-string">"123456789012"</span>
</code></pre>
<p>Replace <code>123456789012</code> with your actual AWS account ID and the region by the one you want to use</p>
<pre><code class="lang-typescript">agent/agent-deploy.ts
<span class="hljs-keyword">import</span>  <span class="hljs-keyword">as</span> pulumi <span class="hljs-keyword">from</span> <span class="hljs-string">"@pulumi/pulumi"</span>;
<span class="hljs-keyword">import</span>  <span class="hljs-keyword">as</span> aws <span class="hljs-keyword">from</span> <span class="hljs-string">"@pulumi/aws"</span>;

<span class="hljs-comment">// Configuration</span>
<span class="hljs-keyword">const</span> config = <span class="hljs-keyword">new</span> pulumi.Config();
<span class="hljs-keyword">const</span> awsRegion = config.require(<span class="hljs-string">"aws_region"</span>);
<span class="hljs-keyword">const</span> accountId = config.require(<span class="hljs-string">"aws_accountId"</span>);
<span class="hljs-keyword">const</span> stack = pulumi.getStack();

<span class="hljs-comment">// Create Bedrock Agent</span>
<span class="hljs-keyword">const</span> bedrockAgent = <span class="hljs-keyword">new</span> aws.bedrock.AgentAgent(my-agent-${stack}, {
agentName: my-agent-${stack},
description: <span class="hljs-string">"A helpful AI assistant"</span>,
agentResourceRoleArn: <span class="hljs-string">"arn:aws:iam::YOUR_ACCOUNT_ID:role/YOUR_BEDROCK_EXECUTION_ROLE"</span>, <span class="hljs-comment">// Replace with your IAM role ARN</span>
idleSessionTtlInSeconds: <span class="hljs-number">500</span>,
foundationModel: arn:aws:bedrock:${awsRegion}:${accountId}:inference-profile/eu.claude<span class="hljs-number">-3</span><span class="hljs-number">-5</span>-sonnet<span class="hljs-number">-20241022</span>-v2:<span class="hljs-number">0</span>,
instruction: <span class="hljs-string">"You are a helpful assistant"</span>
});

<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> agentId = bedrockAgent.id;
<span class="hljs-keyword">export</span> <span class="hljs-keyword">const</span> agentArn = bedrockAgent.agentArn;
</code></pre>
<pre><code class="lang-typescript">index.ts
Replace the <span class="hljs-keyword">default</span> content <span class="hljs-keyword">with</span>:
<span class="hljs-keyword">import</span> { agentId, agentArn } <span class="hljs-keyword">from</span> <span class="hljs-string">"./agent/agent-deploy"</span>;
<span class="hljs-keyword">export</span> { agentId, agentArn };
</code></pre>
<h2 id="heading-required-iam-role"><strong>Required IAM Role</strong></h2>
<p>Important: You must create the IAM role before deploying the agent, otherwise the deployment will fail.</p>
<p><strong>Create IAM Role</strong></p>
<ol>
<li><p>Go to AWS IAM Console</p>
</li>
<li><p>Create a new role with these settings:</p>
<ul>
<li><p>Trusted entity: AWS service</p>
</li>
<li><p>Service: Bedrock</p>
</li>
<li><p>Use case: Bedrock - Agents</p>
</li>
</ul>
</li>
<li><p>Attach this policy to the role:</p>
</li>
</ol>
<pre><code class="lang-json">{
    <span class="hljs-attr">"Version"</span>: <span class="hljs-string">"2012-10-17"</span>,
    <span class="hljs-attr">"Statement"</span>: [
        {
            <span class="hljs-attr">"Effect"</span>: <span class="hljs-string">"Allow"</span>,
            <span class="hljs-attr">"Action"</span>: [
                <span class="hljs-string">"bedrock:InvokeModel"</span>
            ],
            <span class="hljs-attr">"Resource"</span>: <span class="hljs-string">"*"</span>
        }
    ]
}
</code></pre>
<ol start="4">
<li><p>Name your role (for example, MyBedrockAgentRole)</p>
</li>
<li><p>Update the agentResourceRoleArn in your code with the full ARN</p>
</li>
</ol>
<h2 id="heading-deployment">Deployment</h2>
<p>Deploy your Bedrock Agent using this command<br /><code>pulumi up</code></p>
<h2 id="heading-testing">Testing</h2>
<p>After deployment:</p>
<ol>
<li><p>Go to AWS Bedrock console</p>
</li>
<li><p>Navigate to Agents</p>
</li>
<li><p>Find your deployed agent</p>
</li>
<li><p>Test using the built-in chat interface</p>
</li>
</ol>
<h2 id="heading-cleaning">Cleaning</h2>
<p>To clean up, don’t forget to run the command <code>pulumi down</code></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>That’s it!<br />You now have a deployed Bedrock Agent that can have conversations with users. The agent uses the Claude 3.5 Sonnet model and follows the instructions you provided.</p>
<p>Useful link: <a target="_blank" href="https://www.pulumi.com/registry/packages/aws/api-docs/bedrock/agentagent/">https://www.pulumi.com/registry/packages/aws/api-docs/bedrock/agentagent/</a></p>
]]></content:encoded></item><item><title><![CDATA[Remote access to your Raspberry Pi]]></title><description><![CDATA[That’s it—I’ve finally decided to start my homelab: a place to experiment, break things, learn, and start all over again.
I had a Raspberry Pi 4B sitting in a box, so I figured, why not jump in?
Discovering What’s on the Pi
I plugged it into my monit...]]></description><link>https://crunchcrunch.me/remote-access-to-your-raspberry-pi</link><guid isPermaLink="true">https://crunchcrunch.me/remote-access-to-your-raspberry-pi</guid><category><![CDATA[Raspberry Pi]]></category><category><![CDATA[Homelab]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Wed, 24 Sep 2025 16:15:16 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/4k8xEFW4_3Q/upload/12533558e65bf7eb4199d697d78a665f.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>That’s it—I’ve finally decided to start my homelab: a place to experiment, break things, learn, and start all over again.</p>
<p>I had a Raspberry Pi 4B sitting in a box, so I figured, <em>why not jump in?</em></p>
<h3 id="heading-discovering-whats-on-the-pi">Discovering What’s on the Pi</h3>
<p>I plugged it into my monitor to see what was on it. Turns out I had installed <strong>Ubuntu MATE desktop</strong> a few years ago. It worked… sort of. I connected to Wi-Fi and started downloading a few things, but every time I opened Firefox, the system froze. After several restarts and failed attempts, I decided Ubuntu MATE wasn’t the right fit—especially with only <strong>2 GB of RAM</strong>.</p>
<h3 id="heading-choosing-the-right-os">Choosing the Right OS</h3>
<p>To save resources, I went with <strong>Raspberry Pi OS Lite</strong> instead of the full desktop version. It boots incredibly fast and gives me a clean terminal-only environment—perfect for setting up a lightweight home server for experimentation.</p>
<h3 id="heading-setting-up-remote-access-ssh">Setting Up Remote Access (SSH)</h3>
<p>Of course, I didn’t want to plug the Pi into a monitor every time I wanted to use it. Remote access via SSH is the way to go, and luckily, it’s very straightforward:</p>
<ol>
<li><p>On your Raspberry Pi, open the terminal and run:</p>
<pre><code class="lang-bash"> sudo raspi-config
</code></pre>
</li>
<li><p>Go to <strong>Interfacing Options</strong> → <strong>SSH</strong> → <strong>Enable</strong> → <strong>OK</strong> → <strong>Finish</strong>.</p>
</li>
<li><p>Find your Pi’s IP address:</p>
<pre><code class="lang-bash"> hostname -I
</code></pre>
</li>
<li><p>From another computer, connect using:</p>
<pre><code class="lang-bash"> ssh &lt;username&gt;@&lt;ip-address&gt;
</code></pre>
</li>
<li><p>The first time you connect, you’ll get a security warning—type <code>yes</code> to proceed. Enter your password when prompted.</p>
</li>
</ol>
<p>You should now see the Raspberry Pi prompt:</p>
<pre><code class="lang-bash">&lt;username&gt;@&lt;hostname&gt; ~ $
</code></pre>
<p>And that’s it—you’re now connected remotely and ready to start experimenting with your homelab!</p>
]]></content:encoded></item><item><title><![CDATA[How to Use Docker Compose Profiles]]></title><description><![CDATA[I recently discovered Docker compose profiles and wanted to share it as it can be useful to someone else.  
Docker Compose profiles let you control which services run without modifying your docker-compose.yml. They’re useful for separating optional s...]]></description><link>https://crunchcrunch.me/how-to-use-docker-compose-profiles</link><guid isPermaLink="true">https://crunchcrunch.me/how-to-use-docker-compose-profiles</guid><category><![CDATA[Docker]]></category><category><![CDATA[Docker compose]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Fri, 19 Sep 2025 06:00:56 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/jOqJbvo1P9g/upload/3c18afc7044209211c9b97595d4d5940.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I recently discovered Docker compose profiles and wanted to share it as it can be useful to someone else.  </p>
<p>Docker Compose <strong>profiles</strong> let you control which services run without modifying your <code>docker-compose.yml</code>. They’re useful for separating optional services (like monitoring tools or debugging containers) from your core stack.</p>
<blockquote>
<p><strong>From Docker documentation:</strong><br /><em>Profiles help you adjust your Compose application for different environments or use cases by selectively activating services. Services can be assigned to one or more profiles; unassigned services start/stop by default, while assigned ones only start/stop when their profile is active. This setup means specific services, like those for debugging or development, can be included in a single compose.yml file and activated only as needed.</em></p>
</blockquote>
<h1 id="heading-how-to-use-profiles-in-your-docker-composeyml">How to use profiles in your docker-compose.yml</h1>
<p><strong>1. Add Profiles to Your Compose File</strong></p>
<p>In your <code>docker-compose.yml</code>, specify the <code>profiles</code> key for optional services:  </p>
<pre><code class="lang-yaml"><span class="hljs-attr">services:</span>
  <span class="hljs-attr">app:</span>
    <span class="hljs-attr">container_name:</span> <span class="hljs-string">my-app</span>
    <span class="hljs-attr">image:</span> <span class="hljs-string">myapp:latest</span>
    <span class="hljs-attr">ports:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">"8080:8080"</span>

  <span class="hljs-attr">db:</span>
    <span class="hljs-attr">container_name:</span> <span class="hljs-string">pg-database</span>
    <span class="hljs-attr">image:</span> <span class="hljs-string">postgres:15</span>

  <span class="hljs-attr">adminer:</span>
    <span class="hljs-attr">container_name:</span> <span class="hljs-string">adminer</span>
    <span class="hljs-attr">image:</span> <span class="hljs-string">adminer</span>
    <span class="hljs-attr">ports:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">"8081:8080"</span>
    <span class="hljs-attr">profiles:</span>
            <span class="hljs-bullet">-</span> <span class="hljs-string">debug</span>
</code></pre>
<p>Here, <code>adminer</code> is tagged with the <code>debug</code> profile, while <code>app</code> and <code>db</code> always run.</p>
<h4 id="heading-2-start-services-with-a-profile"><strong>2. Start Services with a Profile</strong></h4>
<p>Run only the default services:</p>
<pre><code class="lang-bash">docker compose up
</code></pre>
<p>Run services including the <code>debug</code> profile:</p>
<pre><code class="lang-bash">docker compose --profile debug up
</code></pre>
<p>That’s it !<br />You can now use profiles to load your local dev tools only when you need them.</p>
]]></content:encoded></item><item><title><![CDATA[How to Solve dependencyFailedException on AWS Bedrock]]></title><description><![CDATA[These days, i’m using AWS Bedrock to create Agents.And i faced this error when testing my agents many times so i decided to write down the workaround that i found.
An error occurred (dependencyFailedException) when calling the InvokeAgent operation: ...]]></description><link>https://crunchcrunch.me/how-to-solve-dependencyfailedexception-on-aws-bedrock</link><guid isPermaLink="true">https://crunchcrunch.me/how-to-solve-dependencyfailedexception-on-aws-bedrock</guid><category><![CDATA[AWS]]></category><category><![CDATA[Amazon Bedrock]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Thu, 07 Aug 2025 12:49:35 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/52jRtc2S_VE/upload/14c5976a31b8af0ad36641bb2abf1b1e.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>These days, i’m using AWS Bedrock to create Agents.<br />And i faced this error when testing my agents many times so i decided to write down the workaround that i found.</p>
<p><code>An error occurred (dependencyFailedException) when calling the InvokeAgent operation: Dependency resource: received model timeout/error exception from Bedrock. Try the request again</code></p>
<p>I’m using Pulumi to deploy my agent like this:</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">const</span> agent = <span class="hljs-keyword">new</span> aws.bedrock.AgentAgent(<span class="hljs-string">"pulumi-example-agent"</span>, {
    agentName: <span class="hljs-string">"pulumi-example-agent"</span>,
    description: <span class="hljs-string">"Pulumi example agent with Lambda integration"</span>,
    agentResourceRoleArn: <span class="hljs-string">`<span class="hljs-subst">${roleArn}</span>`</span>,
    idleSessionTtlInSeconds: <span class="hljs-number">500</span>,
    foundationModel: <span class="hljs-string">"arn:aws:bedrock:eu-west-1:XXXXXXXXXXXXXXX:inference-profile/eu.amazon.nova-pro-v1:0"</span>,  
    instruction: <span class="hljs-string">`You are a helpful assistant that can answer questions and help with tasks.`</span>,
})
</code></pre>
<p>I had no issue on the deployment using Github Actions.<br />But when i tried to chat with my agent, i got the error.<br />After trying many things, i decided to swap out the Nova model for a Mistral one.</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">const</span> agent = <span class="hljs-keyword">new</span> aws.bedrock.AgentAgent(<span class="hljs-string">"pulumi-example-agent"</span>, {
    agentName: <span class="hljs-string">"pulumi-example-agent"</span>,
    description: <span class="hljs-string">"Pulumi example agent with Lambda integration"</span>,
    agentResourceRoleArn: <span class="hljs-string">`<span class="hljs-subst">${roleArn}</span>`</span>,
    idleSessionTtlInSeconds: <span class="hljs-number">500</span>,
    foundationModel: <span class="hljs-string">"arn:aws:bedrock:eu-west-1:XXXXXXXXXXXXXXX:inference-profile/eu.mistral.pixtral-large-2502-v1:0"</span>,  
    instruction: <span class="hljs-string">`You are a helpful assistant that can answer questions and help with tasks.`</span>,
})
</code></pre>
<p>Redeployed targeting the new model, and … it worked !<br />No more weird error !<br />So if you face that issue, just ditch the Amazon Nova model for another one !  </p>
<p>See you in the next one ;)</p>
]]></content:encoded></item><item><title><![CDATA[Scenarios for AWS Solutions Architect Associate Certification]]></title><description><![CDATA[Scenarios for AWS Solutions Architect Associate Certification
I'm using this guide to prepare for the AWS Solutions Architect Associate certification. It covers common scenarios to help me understand which AWS services to use for different needs. By ...]]></description><link>https://crunchcrunch.me/scenarios-for-aws-solutions-architect-associate-certification</link><guid isPermaLink="true">https://crunchcrunch.me/scenarios-for-aws-solutions-architect-associate-certification</guid><category><![CDATA[AWS]]></category><category><![CDATA[Cloud]]></category><category><![CDATA[Certification]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Sun, 05 Jan 2025 23:00:37 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/dCTrj3U50oY/upload/b163a4269b2c20f4eab1d62fd4393240.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-scenarios-for-aws-solutions-architect-associate-certification">Scenarios for AWS Solutions Architect Associate Certification</h3>
<p>I'm using this guide to prepare for the AWS Solutions Architect Associate certification. It covers common scenarios to help me understand which AWS services to use for different needs. By learning these, I’ll be better prepared to design secure and efficient solutions for the exam.</p>
<h3 id="heading-compute"><strong>Compute</strong></h3>
<ol>
<li><p><strong>Run applications with minimal administration?</strong><br /> <strong>Think AWS Lambda.</strong></p>
</li>
<li><p><strong>Need virtual servers in the cloud?</strong><br /> <strong>Think Amazon EC2.</strong></p>
</li>
<li><p><strong>Automatically adjust compute capacity to match demand?</strong><br /> <strong>Think Auto Scaling.</strong></p>
</li>
<li><p><strong>Run containerized applications?</strong><br /> <strong>Think Amazon ECS/EKS (Elastic Container Service / Elastic Kubernetes Service).</strong></p>
</li>
<li><p><strong>Simplify container orchestration without managing servers?</strong><br /> <strong>Think AWS Fargate.</strong></p>
</li>
</ol>
<hr />
<h3 id="heading-storage"><strong>Storage</strong></h3>
<ol start="6">
<li><p><strong>Store files and access them globally?</strong><br /> <strong>Think Amazon S3.</strong></p>
</li>
<li><p><strong>Store infrequently accessed data but still need millisecond retrieval?</strong><br /> <strong>Think S3 Standard-IA.</strong></p>
</li>
<li><p><strong>Archive data at the lowest cost?</strong><br /> <strong>Think S3 Glacier or Glacier Deep Archive.</strong></p>
</li>
<li><p><strong>Shared file storage for EC2 instances?</strong><br /> <strong>Think Amazon EFS (Elastic File System).</strong></p>
</li>
<li><p><strong>Block storage for EC2 instances?</strong><br /><strong>Think Amazon EBS (Elastic Block Store).</strong></p>
</li>
<li><p><strong>Transfer large datasets to AWS physically?</strong><br /><strong>Think AWS Snowball.</strong></p>
</li>
</ol>
<hr />
<h3 id="heading-databases"><strong>Databases</strong></h3>
<ol start="12">
<li><p><strong>Managed relational database?</strong><br /><strong>Think Amazon RDS.</strong></p>
</li>
<li><p><strong>NoSQL key-value database?</strong><br /><strong>Think Amazon DynamoDB.</strong></p>
</li>
<li><p><strong>Low-latency caching layer for databases?</strong><br /><strong>Think Amazon ElastiCache.</strong></p>
</li>
<li><p><strong>Petabyte-scale data warehouse?</strong><br /><strong>Think Amazon Redshift.</strong></p>
</li>
<li><p><strong>Migrate databases with minimal downtime?</strong><br /><strong>Think AWS Database Migration Service (DMS).</strong></p>
</li>
</ol>
<hr />
<h3 id="heading-networking"><strong>Networking</strong></h3>
<ol start="17">
<li><p><strong>Distribute traffic across multiple Availability Zones?</strong><br /><strong>Think Elastic Load Balancer (ELB).</strong></p>
</li>
<li><p><strong>Deliver content with low latency worldwide?</strong><br /><strong>Think Amazon CloudFront.</strong></p>
</li>
<li><p><strong>Privately connect services across VPCs?</strong><br /><strong>Think VPC Peering or AWS PrivateLink.</strong></p>
</li>
<li><p><strong>Allow private subnet instances to access the internet?</strong><br /><strong>Think NAT Gateway.</strong></p>
</li>
<li><p><strong>Securely connect your on-premises data center to AWS?</strong><br /><strong>Think AWS VPN or AWS Direct Connect.</strong></p>
</li>
<li><p><strong>Create isolated sections of your AWS environment for security?</strong><br /><strong>Think VPC (Virtual Private Cloud).</strong></p>
</li>
<li><p><strong>Host internal applications with a private DNS?</strong><br /><strong>Think Amazon Route 53 (Private Hosted Zones).</strong></p>
</li>
<li><p><strong>Automatically assign public IP addresses to resources?</strong><br /><strong>Think Elastic IP.</strong></p>
</li>
<li><p><strong>Extend private IP address space to handle more resources?</strong><br /><strong>Think VPC CIDR Blocks.</strong></p>
</li>
<li><p><strong>Secure traffic between services with encrypted endpoints?</strong><br /><strong>Think AWS PrivateLink.</strong></p>
</li>
<li><p><strong>Inspect and filter network traffic to secure your VPC?</strong><br /><strong>Think Network Access Control Lists (NACLs) or Security Groups.</strong></p>
</li>
<li><p><strong>Monitor and analyze network traffic patterns?</strong><br /><strong>Think VPC Flow Logs.</strong></p>
</li>
<li><p><strong>Implement high availability for DNS routing?</strong><br /><strong>Think Amazon Route 53 (Health Checks and Failover Routing).</strong></p>
</li>
<li><p><strong>Direct user traffic based on latency to endpoints worldwide?</strong><br /><strong>Think Amazon Route 53 Latency Routing.</strong></p>
</li>
<li><p><strong>Need a managed firewall solution for web traffic?</strong><br /><strong>Think AWS Network Firewall.</strong></p>
</li>
<li><p><strong>Accelerate data transfer between AWS regions?</strong><br /><strong>Think AWS Global Accelerator.</strong></p>
</li>
<li><p><strong>Secure your web application from threats?</strong><br /><strong>Think AWS WAF (Web Application Firewall).</strong></p>
</li>
<li><p><strong>Monitor and troubleshoot connectivity issues?</strong><br /><strong>Think Reachability Analyzer.</strong></p>
</li>
<li><p><strong>Create redundant connections between your data center and AWS?</strong><br /><strong>Think AWS Direct Connect + Direct Connect Gateway.</strong></p>
</li>
<li><p><strong>Automatically block malicious traffic at the network layer?</strong><br /><strong>Think AWS Shield Advanced.</strong></p>
</li>
</ol>
<hr />
<h3 id="heading-security"><strong>Security</strong></h3>
<ol start="37">
<li><p><strong>Monitor API calls across your AWS account?</strong><br /><strong>Think CloudTrail.</strong></p>
</li>
<li><p><strong>Monitor resource health and set alarms?</strong><br /><strong>Think CloudWatch.</strong></p>
</li>
<li><p><strong>Automate compliance and security checks?</strong><br /><strong>Think AWS Config.</strong></p>
</li>
<li><p><strong>Detect threats and suspicious activity?</strong><br /><strong>Think Amazon GuardDuty.</strong></p>
</li>
<li><p><strong>Centralized management of access across multiple accounts?</strong><br /><strong>Think AWS IAM Identity Center (formerly AWS SSO).</strong></p>
</li>
<li><p><strong>Protect against DDoS attacks?</strong><br /><strong>Think AWS Shield.</strong></p>
</li>
<li><p><strong>Inspect and secure application traffic?</strong><br /><strong>Think AWS WAF (Web Application Firewall).</strong></p>
</li>
<li><p><strong>Securely store and retrieve secrets?</strong><br /><strong>Think AWS Secrets Manager.</strong></p>
</li>
</ol>
<hr />
<h3 id="heading-migration-amp-hybrid"><strong>Migration &amp; Hybrid</strong></h3>
<ol start="45">
<li><p><strong>Quickly migrate virtual machines?</strong><br /><strong>Think AWS Server Migration Service.</strong></p>
</li>
<li><p><strong>Set up a hybrid cloud environment?</strong><br /><strong>Think AWS Outposts.</strong></p>
</li>
</ol>
<hr />
<h3 id="heading-analytics"><strong>Analytics</strong></h3>
<ol start="47">
<li><p><strong>Run big data processing jobs?</strong><br /><strong>Think Amazon EMR (Elastic MapReduce).</strong></p>
</li>
<li><p><strong>Real-time data streaming?</strong><br /><strong>Think Amazon Kinesis.</strong></p>
</li>
<li><p><strong>Search and analyze log data?</strong><br /><strong>Think Amazon OpenSearch Service (formerly Elasticsearch Service).</strong></p>
</li>
<li><p><strong>Managed business intelligence service?</strong><br /><strong>Think Amazon QuickSight.</strong></p>
</li>
</ol>
<hr />
<h3 id="heading-cost-management"><strong>Cost Management</strong></h3>
<ol start="51">
<li><p><strong>Analyze and optimize costs?</strong><br /><strong>Think AWS Cost Explorer.</strong></p>
</li>
<li><p><strong>Receive alerts when costs exceed thresholds?</strong><br /><strong>Think AWS Budgets.</strong></p>
</li>
</ol>
<hr />
<h3 id="heading-machine-learning"><strong>Machine Learning</strong></h3>
<ol start="53">
<li><p><strong>Build and train machine learning models?</strong><br /><strong>Think Amazon SageMaker.</strong></p>
</li>
<li><p><strong>Translate text into other languages?</strong><br /><strong>Think Amazon Translate.</strong></p>
</li>
<li><p><strong>Convert text to speech?</strong><br /><strong>Think Amazon Polly.</strong></p>
</li>
<li><p><strong>Extract text and data from documents?</strong><br /><strong>Think Amazon Textract.</strong></p>
</li>
</ol>
<hr />
]]></content:encoded></item><item><title><![CDATA[Boost Amazon RDS Performance with io2 Block Express Storage]]></title><description><![CDATA[Amazon Relational Database Service (RDS) now offers io2 Block Express storage volumes, enhancing performance for production workloads. These volumes provide consistent sub-millisecond latency, 99.999% durability, and support up to 256,000 Provisioned...]]></description><link>https://crunchcrunch.me/boost-amazon-rds-performance-with-io2-block-express-storage</link><guid isPermaLink="true">https://crunchcrunch.me/boost-amazon-rds-performance-with-io2-block-express-storage</guid><category><![CDATA[AWS]]></category><category><![CDATA[Cloud]]></category><category><![CDATA[rds]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Tue, 31 Dec 2024 07:00:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/lRoX0shwjUQ/upload/aed89c7ba3693367c09366c71da08a5c.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Amazon Relational Database Service (RDS) now offers io2 Block Express storage volumes, enhancing performance for production workloads. These volumes provide consistent sub-millisecond latency, 99.999% durability, and support up to 256,000 Provisioned IOPS and 4,000 MiB/s throughput, making them ideal for I/O-intensive, mission-critical database applications. (<a target="_blank" href="https://aws.amazon.com/blogs/database/optimize-amazon-rds-performance-with-io2-block-express-storage-for-production-workloads/">Read more on AWS</a>)</p>
<p>In performance benchmarks, io2 Block Express volumes consistently outperformed gp3 and io1 volumes across various database engines and configurations. They delivered higher performance with up to 66% lower disk latency compared to gp3, making io2 Block Express particularly suitable for workloads requiring high throughput and low latency.</p>
<h3 id="heading-getting-started-with-io2-block-express">Getting Started with io2 Block Express</h3>
<p>To get started with io2 Block Express, you can create a new RDS instance or modify an existing one via the Amazon RDS console or the AWS CLI.</p>
<p><strong>Creating a New RDS Instance with io2 Block Express:</strong></p>
<pre><code class="lang-bash">aws rds create-db-instance \
    --db-instance-identifier mydbinstance \
    --db-instance-class db.m5.large \
    --engine mysql \
    --master-username admin \
    --master-user-password password \
    --allocated-storage 100 \
    --storage-type io2 \
    --iops 1000
</code></pre>
<p><strong>Modifying an Existing RDS Instance:</strong></p>
<pre><code class="lang-bash">aws rds modify-db-instance \
    --db-instance-identifier mydbinstance \
    --storage-type io2 \
    --iops 1000 \
    --apply-immediately
</code></pre>
<p>After modifying the instance, a storage optimization process begins, and further modifications are deferred until it completes. A progress indicator provides visibility into this process. It's recommended to evaluate performance and costs according to your application requirements and test any changes prior to production deployment.</p>
<h3 id="heading-regional-availability">Regional Availability</h3>
<p>io2 Block Express volumes are available in multiple AWS Regions, including US East (N. Virginia, Ohio), US West (N. California, Oregon), Asia Pacific (Hong Kong, Mumbai, Seoul, Singapore, Sydney, Tokyo), Canada (Central), Europe (Frankfurt, Ireland, London, Stockholm), and Middle East (Bahrain).</p>
<p>For more detailed information, refer to the original AWS Database Blog post: <a target="_blank" href="https://aws.amazon.com/blogs/database/optimize-amazon-rds-performance-with-io2-block-express-storage-for-production-workloads/">Optimize Amazon RDS Performance with io2 Block Express Storage</a>.</p>
]]></content:encoded></item><item><title><![CDATA[RDS Blue-Green Deployment for major upgrade]]></title><description><![CDATA[Advantages of RDS Blue-Green Deployment
RDS Blue-Green Deployment offers a compelling alternative to traditional approaches, providing several key advantages:

Simplicity: This model simplifies the deployment process, reducing the likelihood of error...]]></description><link>https://crunchcrunch.me/rds-blue-green-deployment-for-major-upgrade</link><guid isPermaLink="true">https://crunchcrunch.me/rds-blue-green-deployment-for-major-upgrade</guid><category><![CDATA[rds]]></category><category><![CDATA[AWS]]></category><category><![CDATA[Cloud]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Sun, 29 Dec 2024 23:00:38 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/VofYoHuMWyc/upload/6be9de8fc73a88d4b125ffdaf13f0fbc.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-advantages-of-rds-blue-green-deployment"><strong>Advantages of RDS Blue-Green Deployment</strong></h3>
<p>RDS Blue-Green Deployment offers a compelling alternative to traditional approaches, providing several key advantages:</p>
<ol>
<li><p><strong>Simplicity</strong>: This model simplifies the deployment process, reducing the likelihood of errors and streamlining operations.</p>
</li>
<li><p><strong>Control and Flexibility</strong>: Blue-Green Deployment enhances control and flexibility, allowing for smoother management of releases with minimal disruption.</p>
</li>
<li><p><strong>Reduced Downtime</strong>: A major benefit is the ability to minimize downtime by seamlessly shifting traffic between two identical environments.</p>
</li>
</ol>
<h3 id="heading-implementation-of-blue-green-deployment"><strong>Implementation of Blue-Green Deployment</strong></h3>
<p>After upgrading to a compatible PostgreSQL version, RDS Blue-Green Deployment was implemented through the following steps:</p>
<ol>
<li><p><strong>Setup of Blue-Green Deployment</strong>:</p>
<ul>
<li>Initiated the creation of a Blue-Green Deployment using an existing PostgreSQL database as the starting point.</li>
</ul>
</li>
<li><p><strong>Topology and Configuration Replication</strong>:</p>
<ul>
<li>RDS replicated the topology and configuration of the primary database to create the Green environment.</li>
</ul>
</li>
<li><p><strong>Data Replication</strong>:</p>
<ul>
<li>Data from the Blue environment was synchronized to the Green environment, ensuring consistency between the two.</li>
</ul>
</li>
<li><p><strong>Major Version Upgrade on Green Environment</strong>:</p>
<ul>
<li>Applied a major version upgrade to the Green environment, preparing it to handle production traffic.</li>
</ul>
</li>
<li><p><strong>Seamless Switchover</strong>:</p>
<ul>
<li>Conducted a smooth transition of traffic from the Blue environment to the Green environment, minimizing disruption.</li>
</ul>
</li>
<li><p><strong>Minimized Downtime</strong>:</p>
<ul>
<li>The switchover process was efficiently executed, resulting in minimal downtime while maintaining system availability.</li>
</ul>
</li>
<li><p><strong>Resource Optimization</strong>:</p>
<ul>
<li>Once the switchover was complete, the Blue-Green Deployment was removed to free up resources.</li>
</ul>
</li>
</ol>
<h3 id="heading-conclusion"><strong>Conclusion</strong></h3>
<p>RDS Blue-Green Deployment proved to be an effective and reliable strategy for minimizing downtime and ensuring a smooth transition during database upgrades. By leveraging this approach, we achieved greater control, flexibility, and simplicity in the deployment process. The seamless switchover and efficient resource utilization highlighted the value of this model, making it a robust solution for managing database transitions with minimal disruption to system availability.</p>
]]></content:encoded></item><item><title><![CDATA[How to restore a snapshot on AWS RDS]]></title><description><![CDATA[Amazon RDS creates a storage volume snapshot of your DB instance, backing up the entire DB instance and not just individual databases.
You can create a new DB instance by restoring from a DB snapshot. You provide the name of the DB snapshot to restor...]]></description><link>https://crunchcrunch.me/how-to-restore-a-snapshot-on-aws-rds</link><guid isPermaLink="true">https://crunchcrunch.me/how-to-restore-a-snapshot-on-aws-rds</guid><category><![CDATA[rds]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Mon, 23 Dec 2024 14:48:57 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/hiXNIBKt4aw/upload/db8ac4dde99fdde868b1432ff1e1441c.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Amazon RDS creates a storage volume snapshot of your DB instance, backing up the entire DB instance and not just individual databases.</p>
<p>You can create a new DB instance by restoring from a DB snapshot. You provide the name of the DB snapshot to restore from, and then provide a name for the new DB instance that is created from the restore.</p>
<p>You can't restore from a DB snapshot to an existing DB instance; a new DB instance is created when you restore.</p>
<h3 id="heading-steps">Steps</h3>
<h6 id="heading-to-restore-a-db-instance-from-a-db-snapshot">To restore a DB instance from a DB snapshot</h6>
<ol>
<li><p>Sign in to the AWS Management Console and open the Amazon RDS console at <a target="_blank" href="https://console.aws.amazon.com/rds/">https://console.aws.amazon.com/rds/</a>.</p>
</li>
<li><p>In the navigation pane, choose <strong>Snapshots</strong>.</p>
</li>
<li><p>Choose the DB snapshot that you want to restore from.</p>
</li>
<li><p>For <strong>Actions</strong>, choose <strong>Restore snapshot</strong>.</p>
</li>
<li><p>On the <strong>Restore snapshot</strong> page, for <strong>DB instance identifier</strong>, enter the name for your restored DB instance.</p>
</li>
<li><p>Specify other settings, such as allocated storage size.</p>
<p> For information about each setting, see <a target="_blank" href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_CreateDBInstance.html#USER_CreateDBInstance.Settings">Settings for DB instances</a>.</p>
</li>
<li><p>Choose <strong>Restore DB instance</strong>.</p>
</li>
</ol>
<h3 id="heading-conclusion">Conclusion</h3>
<p>Now you know how to restore a snapshot on RDS.<br />See you in the next one!</p>
]]></content:encoded></item><item><title><![CDATA[How to use AWS DMS to perform a major version upgrade on RDS]]></title><description><![CDATA[Upgrading the major version of your Amazon RDS (Relational Database Service) instance is a crucial task to keep your database up-to-date with the latest features, security patches, and performance improvements. AWS Database Migration Service (DMS) ca...]]></description><link>https://crunchcrunch.me/how-to-use-aws-dms-to-perform-a-major-version-upgrade-on-rds</link><guid isPermaLink="true">https://crunchcrunch.me/how-to-use-aws-dms-to-perform-a-major-version-upgrade-on-rds</guid><category><![CDATA[AWS RDS]]></category><category><![CDATA[aws dms]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Thu, 16 Nov 2023 16:53:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/AcW1ZwD-qC0/upload/d47f87f5b0ea9bfee83250fdb6f94bc9.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Upgrading the major version of your Amazon RDS (Relational Database Service) instance is a crucial task to keep your database up-to-date with the latest features, security patches, and performance improvements. AWS Database Migration Service (DMS) can be a powerful tool to assist you in performing a major version upgrade on your RDS instance seamlessly. In this article, we will explore how to use AWS DMS for this purpose.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>Before we dive into using AWS DMS for a major version upgrade, ensure you have the following prerequisites in place:</p>
<ol>
<li><p><strong>Amazon Web Services Account</strong>: You need an AWS account with the necessary permissions to perform these operations.</p>
</li>
<li><p><strong>Amazon RDS Instance</strong>: You should have an existing RDS instance that you want to upgrade.</p>
</li>
</ol>
<h2 id="heading-step-by-step-guide">Step-by-Step Guide</h2>
<h3 id="heading-1-create-a-custom-parameter-group">1. Create a Custom Parameter Group</h3>
<p>Create a parameter group for the target DB with rds.logical_replication at 1 and rds.force_ssl at 0 (to allow the connection during the migration)</p>
<h3 id="heading-2-create-the-target-db-and-associate-the-parameter-group">2. Create the target DB and associate the Parameter Group</h3>
<p>In the RDS console, create a new RDS instance with the desired major version. Associate the custom parameter group you created in the previous step with your target DB.</p>
<h3 id="heading-3-create-a-replication-instance">3. Create a Replication Instance</h3>
<p>A replication instance acts as the computing and memory resource for your migration task. You can create a new replication instance or use an existing one.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1700153275080/10e4394d-4435-43ab-b261-a7aa4cd0121d.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-4-configure-source-and-target-endpoints">4. Configure Source and Target Endpoints</h3>
<p>In the AWS DMS console, navigate to your DMS instance, and configure the source and target endpoints. The source endpoint should point to your existing RDS instance, and the target endpoint should point to your new RDS instance with the upgraded database engine.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1700153319062/c69f173e-81bd-4a2b-b223-b847210bf5cd.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-5-create-a-migration-task">5. Create a Migration Task</h3>
<p>Create a new migration task in the AWS DMS console and associate it with the source and target endpoints you configured in the previous steps. Specify the migration type as 'Migrate existing data and replicate ongoing changes.'</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1700153381953/1d11e3d2-f79d-42bf-b8bc-c41f4505dfc0.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-6-choose-a-data-migration-method">6. Choose a Data Migration Method</h3>
<p>AWS DMS offers various data migration methods, such as Full Load and CDC (Change Data Capture). For a major version upgrade, it's advisable to use the CDC method to minimize downtime.</p>
<h3 id="heading-7-start-the-migration-task">7. Start the Migration Task</h3>
<p>Once your migration task is configured, start it. AWS DMS will begin copying data and changes from your source RDS instance to the target RDS instance.</p>
<h3 id="heading-8-monitor-and-verify">8. Monitor and Verify</h3>
<p>Monitor the progress of your migration task using the DMS console. AWS DMS provides real-time status updates and logs to ensure the migration is proceeding as expected.</p>
<h3 id="heading-9-test-your-applications">9. Test Your Applications</h3>
<p>Before finalizing the upgrade, thoroughly test your applications against the new RDS instance to ensure everything works as expected. This step is crucial to identify any potential issues early.</p>
<h3 id="heading-10-cutover-to-the-new-rds-instance">10. Cutover to the New RDS Instance</h3>
<p>When you are confident that the upgrade is successful and your applications are running smoothly on the new RDS instance, you can plan a cutover. This involves redirecting your applications to use the new RDS instance. This is typically a brief, controlled downtime.</p>
<h3 id="heading-11-complete-the-migration">11. Complete the Migration</h3>
<p>After the cutover, you can stop your DMS migration task. The new RDS instance is now running the upgraded database engine, and you can decommission the old instance if necessary.</p>
<h1 id="heading-best-practices">Best Practices</h1>
<p>Here are some best practices to ensure a successful major version upgrade using AWS DMS:</p>
<ul>
<li><p><strong>Backup and Snapshot</strong>: Always take a snapshot of your existing RDS instance before starting the upgrade process. This allows you to roll back in case of any issues.</p>
</li>
<li><p><strong>Test Thoroughly</strong>: Extensive testing is crucial to avoid post-upgrade problems. Test all aspects of your application to ensure compatibility with the new database engine version.</p>
</li>
<li><p><strong>Plan for Downtime</strong>: While AWS DMS minimizes downtime, there may still be some downtime during cutover. Plan for this and communicate it to your users.</p>
</li>
<li><p><strong>Monitor Performance</strong>: After the upgrade, closely monitor the performance of your new RDS instance to ensure it meets your requirements.</p>
</li>
<li><p><strong>Stay Informed</strong>: Keep an eye on AWS announcements for any new major versions, features, or security updates relevant to your database engine.</p>
</li>
</ul>
<h1 id="heading-conclusion">Conclusion</h1>
<p>Upgrading the major version of your Amazon RDS instance is essential to maintain the security, performance, and features of your database. AWS DMS can help you streamline the process, minimize downtime, and reduce the risks associated with major version upgrades. By following the steps and best practices outlined in this article, you can ensure a smooth and successful upgrade for your RDS instance.</p>
]]></content:encoded></item><item><title><![CDATA[How to setup Github Actions to use a private repository as a dependency]]></title><description><![CDATA[A few weeks ago, I encountered a challenging situation, prompting me to write this article to assist others facing a similar issue.
Scenario
I maintained a private repository that hosted the code for my application. Additionally, I created a separate...]]></description><link>https://crunchcrunch.me/how-to-setup-github-actions-to-use-a-private-repository-as-a-dependency</link><guid isPermaLink="true">https://crunchcrunch.me/how-to-setup-github-actions-to-use-a-private-repository-as-a-dependency</guid><category><![CDATA[github-actions]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Tue, 31 Oct 2023 18:24:14 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/MAYEkmn7G6E/upload/1d9b056a0ee3b82e67a3004159f6fc75.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A few weeks ago, I encountered a challenging situation, prompting me to write this article to assist others facing a similar issue.</p>
<h3 id="heading-scenario">Scenario</h3>
<p>I maintained a private repository that hosted the code for my application. Additionally, I created a separate private repository for a new library I developed. My objective was to use this library as a dependency in my primary project.</p>
<p>Locally, everything functioned smoothly, primarily due to my SSH key setup. However, when it came to GitHub Actions, I ran into difficulties. The stumbling block was my use of a personal access token (PAT) from a machine user. Specifically, I encountered errors during the <code>npm ci</code> step, primarily stemming from permission issues.</p>
<h3 id="heading-solution">Solution</h3>
<p>This is how I have managed to install dependencies from private GitHub repositories.</p>
<pre><code class="lang-typescript">package.json

 <span class="hljs-string">"dependencies"</span>: {
        ...
        <span class="hljs-string">"pg"</span>: <span class="hljs-string">"8.6.0"</span>,
        <span class="hljs-string">"myprivatelib"</span>: <span class="hljs-string">"orgName/myprivateRepo"</span>
    },
</code></pre>
<pre><code class="lang-yaml"><span class="hljs-comment"># Github Action</span>

<span class="hljs-bullet">-</span> <span class="hljs-attr">uses:</span> <span class="hljs-string">actions/checkout@v3</span>
   <span class="hljs-attr">with:</span>
       <span class="hljs-attr">persist-credentials:</span> <span class="hljs-literal">false</span>
<span class="hljs-bullet">-</span> <span class="hljs-attr">uses:</span> <span class="hljs-string">actions/setup-node@v1</span>
  <span class="hljs-attr">with:</span>
      <span class="hljs-attr">node-version:</span> <span class="hljs-number">16.</span><span class="hljs-string">x</span>
<span class="hljs-bullet">-</span> <span class="hljs-attr">run:</span> <span class="hljs-string">git</span> <span class="hljs-string">config</span> <span class="hljs-string">--global</span> <span class="hljs-string">url."https://${{</span> <span class="hljs-string">secrets.PAT</span> <span class="hljs-string">}}@github.com/".insteadOf</span> <span class="hljs-string">ssh://git@github.com/</span>
<span class="hljs-bullet">-</span> <span class="hljs-attr">run:</span> <span class="hljs-string">npm</span> <span class="hljs-string">ci</span>
</code></pre>
<p>It is important to disable persisted credentials on <code>actions/checkout</code>, otherwise they will override your <code>PAT</code>.  </p>
<p>Your GitHub action should run without any issues now!</p>
]]></content:encoded></item><item><title><![CDATA[How to set up DynamoDB locally]]></title><description><![CDATA[Do you know that can use the local version of Amazon DynamoDB to develop and test applications without having to access the DynamoDB web service?This local version helps you save on throughput, data storage, and data transfer fees. Moreover, it enabl...]]></description><link>https://crunchcrunch.me/how-to-set-up-dynamodb-locally</link><guid isPermaLink="true">https://crunchcrunch.me/how-to-set-up-dynamodb-locally</guid><category><![CDATA[AWS]]></category><category><![CDATA[DynamoDB]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Mon, 15 May 2023 16:04:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/GNyjCePVRs8/upload/7e43a424bbf0a085c02553a338642b53.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Do you know that can use the local version of Amazon DynamoDB to develop and test applications without having to access the DynamoDB web service?<br />This local version helps you save on throughput, data storage, and data transfer fees. Moreover, it enables you to test your applications without having to worry about internet connectivity.</p>
<p>As a developer, you can use the local version of DynamoDB to simulate real-world scenarios and test the limits of your application. You can also use it to debug and troubleshoot issues in a controlled environment. By using the local version, you can speed up your development process and reduce your overall development costs.</p>
<h3 id="heading-setup-with-docker-compose">Setup with Docker compose</h3>
<p>A local version of Amazon DynamoDB is available as a Docker image.<br />For more information, see <a target="_blank" href="https://hub.docker.com/r/amazon/dynamodb-local">dynamodb-local</a>.</p>
<p>To install and run DynamoDB locally with Docker compose (Docker must be installed):</p>
<p>Copy the following code to a file and save it as <code>docker-compose.yml</code>.</p>
<pre><code class="lang-yaml"><span class="hljs-attr">version:</span> <span class="hljs-string">'3.8'</span>
<span class="hljs-attr">services:</span>
  <span class="hljs-attr">dynamodb-local:</span>
    <span class="hljs-attr">command:</span> <span class="hljs-string">"-jar DynamoDBLocal.jar -sharedDb -dbPath ./data"</span>
    <span class="hljs-attr">image:</span> <span class="hljs-string">"amazon/dynamodb-local:latest"</span>
    <span class="hljs-attr">container_name:</span> <span class="hljs-string">dynamodb-local</span>
    <span class="hljs-attr">ports:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">"8000:8000"</span>
    <span class="hljs-attr">volumes:</span>
      <span class="hljs-bullet">-</span> <span class="hljs-string">"./docker/dynamodb:/home/dynamodblocal/data"</span>
    <span class="hljs-attr">working_dir:</span> <span class="hljs-string">/home/dynamodblocal</span>
</code></pre>
<p>Run the following command:</p>
<pre><code class="lang-bash">docker-compose up
</code></pre>
<p>Your local DynamoDB is ready to be used.<br />You can use the AWS CLI to interact with your local DB using the <code>--endpoint-url</code> parameter</p>
<pre><code class="lang-bash">aws dynamodb list-tables --endpoint-url http://localhost:8000
</code></pre>
<p>You can also use dynamodb-admin to have a GUI to interact with your local database</p>
<p><a target="_blank" href="https://www.npmjs.com/package/dynamodb-admin">https://www.npmjs.com/package/dynamodb-admin</a></p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>That's it!</p>
<p>Don't hesitate to comment if you have any questions.</p>
<p>See you in the next one! 🤖🤖🤖</p>
]]></content:encoded></item><item><title><![CDATA[How to deploy a serverless application using Github Actions]]></title><description><![CDATA[This article will explain how to deploy a serverless application using GitHub Actions.
GitHub repository

Create a new repository on GitHub, or choose an existing repository that you want to set up the action for.

In the .github/workflows directory ...]]></description><link>https://crunchcrunch.me/how-to-deploy-a-serverless-application-using-github-actions</link><guid isPermaLink="true">https://crunchcrunch.me/how-to-deploy-a-serverless-application-using-github-actions</guid><category><![CDATA[AWS]]></category><category><![CDATA[GitHub Actions]]></category><category><![CDATA[serverless]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Fri, 06 Jan 2023 09:55:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/f67975554bae2f05efaac85b850145cb.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>This article will explain how to deploy a serverless application using GitHub Actions.</p>
<h3 id="heading-github-repository">GitHub repository</h3>
<ol>
<li><p>Create a new repository on GitHub, or choose an existing repository that you want to set up the action for.</p>
</li>
<li><p>In the <code>.github/workflows</code> directory of your repository, create a new file for your action. You can name this file anything you like, but it should have the <code>.yml</code> file extension.</p>
</li>
<li><p>In the action file, define a new job with the <code>name</code> and <code>on</code> properties. The <code>on</code> property specifies when the job should be run, such as when a push event is made to some branch of the repository or when a pull request is made.</p>
</li>
<li><p>In the job, define a <code>steps</code> section that contains one or more steps. Each step is an individual task that the job should perform.</p>
</li>
<li><p>For the first step, use the <code>uses</code> property to specify an action. First, we are using an action named <em>actions/checkout@v2</em>. This is an action provided by GitHub that will check out your repository onto the runner, so that it can be built and tested.</p>
</li>
<li><p>Then, we are using another action named <a target="_blank" href="https://github.com/serverless/github-action"><em>serverless/github-action@v3.1</em></a><em>.</em> This is an action provided by the Serverless team that wraps the Serverless Framework to enable common Serverless commands.</p>
</li>
<li><p>For subsequent steps, you can use the <code>run</code> property to run a command using the Serverless Framework. For example, you can use <code>run: serverless deploy</code> to deploy your serverless application to the cloud.</p>
</li>
<li><p>Set up any necessary environment variables that the Serverless Framework needs. For example, you may need to set the <code>AWS_ACCESS_KEY_ID</code> and <code>AWS_SECRET_ACCESS_KEY</code> environment variables to provide the action with access to your AWS account.</p>
</li>
<li><p>Commit and push your changes to the repository. This will trigger the GitHub Action to run.</p>
</li>
</ol>
<h3 id="heading-example-file">Example file</h3>
<p>Here is an example action file that demonstrates these steps:</p>
<pre><code class="lang-yaml"><span class="hljs-attr">Copy codename:</span> <span class="hljs-string">Deploy</span> <span class="hljs-string">Serverless</span> <span class="hljs-string">Application</span>

<span class="hljs-attr">on:</span>
  <span class="hljs-attr">push:</span>
    <span class="hljs-attr">branches:</span> [ <span class="hljs-string">main</span> ]

<span class="hljs-attr">jobs:</span>
  <span class="hljs-attr">deploy:</span>
    <span class="hljs-attr">runs-on:</span> <span class="hljs-string">ubuntu-latest</span>
    <span class="hljs-attr">steps:</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">uses:</span> <span class="hljs-string">actions/checkout@v3</span>
    <span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">Deploy</span> <span class="hljs-string">Serverless</span> <span class="hljs-string">Application</span>
      <span class="hljs-attr">uses:</span> <span class="hljs-string">serverless/github-action@v3.1</span>
      <span class="hljs-attr">with:</span>
        <span class="hljs-attr">args:</span> <span class="hljs-string">deploy</span>
      <span class="hljs-attr">env:</span>
        <span class="hljs-attr">AWS_ACCESS_KEY_ID:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.AWS_ACCESS_KEY_ID</span> <span class="hljs-string">}}</span>
        <span class="hljs-attr">AWS_SECRET_ACCESS_KEY:</span> <span class="hljs-string">${{</span> <span class="hljs-string">secrets.AWS_SECRET_ACCESS_KEY</span> <span class="hljs-string">}}</span>
</code></pre>
<p>This action will run when a push event is made to the <code>main</code> branch, and it will deploy the serverless application using the <code>serverless deploy</code> command.</p>
<p>I hope this helps! Let me know if you have any questions.</p>
]]></content:encoded></item><item><title><![CDATA[Simple explanation : what is the difference between Intel , AMD & ARM processors ?]]></title><description><![CDATA[I've been working for some months on a Macbook M1, and i had to adapt in order to make some applications work on my machine, but i did not know very well the reason about that, so i decided to dig a new subject : Processors
Definition
What is a Proce...]]></description><link>https://crunchcrunch.me/simple-explanation-what-is-the-difference-between-intel-amd-arm-processors</link><guid isPermaLink="true">https://crunchcrunch.me/simple-explanation-what-is-the-difference-between-intel-amd-arm-processors</guid><category><![CDATA[ARM]]></category><category><![CDATA[Intel]]></category><category><![CDATA[cpu]]></category><category><![CDATA[amd]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Fri, 16 Sep 2022 08:30:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/wl8hZoJBSU8/upload/v1662208919553/bZPU4Y0Ld.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I've been working for some months on a Macbook M1, and i had to adapt in order to make some applications work on my machine, but i did not know very well the reason about that, so i decided to dig a new subject : Processors</p>
<h3 id="heading-definition">Definition</h3>
<p><em>What is a Processor ?</em></p>
<p>Also known as Central Processing Units (CPUs), a processor is a small chip that act as brains for computers and smartphones. The CPU is responsible for calculations, caching critical information for quick access, and more.</p>
<h3 id="heading-manufacturers-vs-architecture">Manufacturers vs Architecture</h3>
<p>Intel and AMD are manufacturers, but ARM processors are a type of architecture, and therefore they do not have only one manufacturer, so it's not really the point to compare them.</p>
<p><strong>Intel</strong></p>
<p>Intel is the most popular and well-known maker of processors.<br />Manufacturers like Dell, Apple, Samsung and HP all use Intel processors in their computers.<br />Intel processors are the most stable and offer the best all-round performance.</p>
<p><strong>AMD</strong></p>
<p>AMD is Intel’s biggest competitor, offering processors that are similar to Intel’s, but at a cheaper price.</p>
<p>Both Intel and AMD produce what we call x86 processors.<br />So finally, the comparaison should be between the two architectures : x86 and ARM</p>
<h3 id="heading-differences">Differences</h3>
<p><strong>X86 &amp; ARM</strong></p>
<p><em>X86</em></p>
<blockquote>
<p>X86 is a family of complex instruction set computer (CISC) instruction set architectures[a] initially developed by Intel based on the Intel 8086 microprocessor.</p>
</blockquote>
<p><em>ARM</em></p>
<blockquote>
<p>ARM is a family of reduced instruction set computer (RISC) instruction set architectures for computer processors, configured for various environments.</p>
</blockquote>
<p>Processors designed by different companies may adopt the same ISA(Instruction Set Architecture); for example, both AMD and Intel CPUs are based on the x86 architecture, which means any operating system or program that can run on an Intel CPU can also run on an AMD CPU.</p>
<p><strong>CISC &amp; RISC</strong></p>
<p><em>CISC</em></p>
<blockquote>
<p>The CISC Stands for Complex Instruction Set Computer, developed by the Intel. It has a large collection of complex instructions that range from simple to very complex and specialized in the assembly language level, which takes a long time to execute the instructions</p>
</blockquote>
<p><em>RISC</em></p>
<blockquote>
<p>RISC stands for Reduced Instruction Set Computer Processor, a microprocessor architecture with a simple collection and highly customized set of instructions. It is built to minimize the instruction execution time by optimizing and limiting the number of instructions.  </p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1662310101370/CZSsi92d4.jpeg" alt="table-1-RISC-CISC.jpeg" /></p>
<p>*ISA : Instruction Set Architecture</p>
<h3 id="heading-arm-smartphones-and-computers">ARM : smartphones and computers</h3>
<p>Arm processors are incredibly energy-efficient and generate less heat. This is crucial for mobile devices such as smartphones, since battery life cannot be too limited, and the device must not get too hot! Arm CPUs are the leading smartphone processor IP on the market today. 95 percent of premium smartphones are powered by Arm.  </p>
<p>Arm is also used in many Chromebook laptops, and Apple now offers a number of computers that use the Arm-based M1 chip (before they used Intel x86 chips).<br />Apple's new MacBook Pro systems, which use the chip, have set a new industry standard for laptop performance and battery life.<br />The Arm processor is also moving into the server market but more slowly.</p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>Now you know that there are two different types of architectures, x86 and arm.<br />The way they work are different and the apps developed for one ISA cannot work on the other one.
That's why, when you get a Macbook M1 (or a Chromebook), you have to adjust and download arm-compatible apps.<br />Don't hesitate to point out some mistakes i've made in the comments, i'm still digging the subject and i wanted to simplify a lot these concepts so maybe i took some shortcuts.</p>
]]></content:encoded></item><item><title><![CDATA[A developer explanation about container images in Lambda]]></title><description><![CDATA[Definition
Container image support for AWS Lambda was announced back at AWS re:Invent 2020.Okay, but what exactly is container image support ?
To understand that, you need to have some context about lambda.
When you create a Lambda function, you pack...]]></description><link>https://crunchcrunch.me/a-developer-explanation-about-container-images-in-lambda</link><guid isPermaLink="true">https://crunchcrunch.me/a-developer-explanation-about-container-images-in-lambda</guid><category><![CDATA[aws lambda]]></category><category><![CDATA[AWS]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Sat, 10 Sep 2022 08:30:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/tjX_sniNzgQ/upload/v1662208852277/QCowRQdGz.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-definition">Definition</h3>
<p>Container image support for AWS Lambda was announced back at AWS re:Invent 2020.<br />Okay, but what exactly is container image support ?</p>
<p>To understand that, you need to have some context about lambda.
When you create a Lambda function, you package your function code into a deployment package.
Before the container image support, the only way to deploy your lambda code was through a zip file.</p>
<h3 id="heading-lambda-with-zip-file">Lambda with zip file</h3>
<p>For example, you had to create the actual code of your lambda , let's say in Node.js</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// index.js</span>
<span class="hljs-built_in">exports</span>.handler =  <span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">event, context</span>) </span>{
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"Hello world"</span>)
}
</code></pre>
<p>To be able to upload your code, you must create a zip file </p>
<p><code>zip function.zip index.js</code></p>
<p>Then upload your package using the update-function-code command</p>
<p><code>aws lambda update-function-code --function-name my-function --zip-file fileb://function.zip</code></p>
<h3 id="heading-lambda-with-container-image">Lambda with container image</h3>
<p>If you use Container image to deploy your function, after creating your image, you can use the Docker CLI build it and push it to AWS ECR (Elastic Container Registry), and then after that create your function from that image.</p>
<p>Let's create an image from the code i showed you above</p>
<pre><code class="lang-docker">FROM public.ecr.aws/lambda/nodejs:16
COPY index.js  ./
CMD [ "app.handler" ]
</code></pre>
<p>Then build that image</p>
<p><code>docker build -t lambda-container-image .</code></p>
<p>And finally, push it to ECR</p>
<ul>
<li>Log in <pre><code class="lang-docker">aws ecr get-login-password  --region &lt;region&gt; | docker login 
   --username AWS --password-stdin     
   &lt;accountID&gt;.dkr.ecr.&lt;region&gt;.amazonaws.com
</code></pre>
</li>
<li>Create the Repository<pre><code class="lang-docker">aws ecr create-repository 
   --repository-name lambda-container-image 
   --image-tag-mutability IMMUTABLE
   --image-scanning-configuration scanOnPush=true
</code></pre>
</li>
<li>Tag the image<pre><code>docker tag lambda<span class="hljs-operator">-</span>container<span class="hljs-operator">-</span>image:v1 <span class="hljs-operator">&lt;</span>accountID<span class="hljs-operator">&gt;</span>.dkr.ecr.&lt;region<span class="hljs-operator">&gt;</span>.amazonaws.com/lambda<span class="hljs-operator">-</span>container<span class="hljs-operator">-</span>image:v1
</code></pre></li>
<li>Push the image<pre><code>docker push <span class="hljs-operator">&lt;</span>accountID<span class="hljs-operator">&gt;</span>.dkr.ecr.&lt;region<span class="hljs-operator">&gt;</span>.amazonaws.com/lambda<span class="hljs-operator">-</span>container<span class="hljs-operator">-</span>image:v1
</code></pre></li>
</ul>
<p>And then, create your function from that image </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1662300672942/VCrba2G0x.png" alt="Capture d’écran 2022-09-04 à 16.04.25.png" /></p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>Now, you know the difference between the two types of deployment packages supported by Lambda.</p>
<p>If you want to know more, once again, check the <a target="_blank" href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-deploy-functions.html">Lambda Documentation</a></p>
<p>See you in the next one :) </p>
]]></content:encoded></item><item><title><![CDATA[Lambda function URLs: deploy and test with CDK]]></title><description><![CDATA[In this article, we are going to discover a new feature from AWS Lambda : function URLs.
Definition
 A function URL is a dedicated HTTP(S) endpoint for your Lambda function.The endpoints have the following format:  
https://<url-id>.lambda-url.<regio...]]></description><link>https://crunchcrunch.me/lambda-function-urls-deploy-and-test-with-cdk</link><guid isPermaLink="true">https://crunchcrunch.me/lambda-function-urls-deploy-and-test-with-cdk</guid><category><![CDATA[AWS]]></category><category><![CDATA[aws lambda]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Thu, 26 May 2022 13:11:46 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/s5kTY-Ve1c0/upload/v1653570657188/BcZF365T3.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In this article, we are going to discover a new feature from AWS Lambda : function URLs.</p>
<h3 id="heading-definition">Definition</h3>
<p> A function URL is a dedicated HTTP(S) endpoint for your Lambda function.<br />The endpoints have the following format:  </p>
<p><code>https://&lt;url-id&gt;.lambda-url.&lt;region&gt;.on.aws</code></p>
<h3 id="heading-pricing">Pricing</h3>
<p>Function URLs are included in Lambda’s request and duration pricing.</p>
<h3 id="heading-difference-with-api-gateway">Difference with API Gateway</h3>
<p>Function URLs are best for use cases where you must implement a single-function microservice with a public endpoint that doesn’t require the advanced functionality of API Gateway, such as request validation, throttling, custom authorizers, custom domain names, usage plans, or caching.<br />For example, when you are implementing webhook handlers, form validators, static html file...<br />It is also the simplest way to invoke your Lambda functions during development without leaving the Lambda console or integrating additional services.</p>
<h3 id="heading-create-and-deploy-the-lambda-with-cdk">Create and deploy the lambda with CDK</h3>
<p>Let's create a new project</p>
<pre><code>mkdir <span class="hljs-keyword">lambda</span>-url
cd <span class="hljs-keyword">lambda</span> url
cdk init
</code></pre><p>lib/lambda-url-stack.ts</p>
<pre><code><span class="hljs-keyword">import</span> { <span class="hljs-title">CfnOutput</span>, <span class="hljs-title">Stack</span>, <span class="hljs-title">StackProps</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'aws-cdk-lib'</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">Construct</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'constructs'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">lambda</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'aws-cdk-lib/aws-lambda'</span>;

export class LambdaHttpStack extends Stack {
  <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params">scope: Construct, id: <span class="hljs-keyword">string</span>, props?: StackProps</span>) </span>{
    <span class="hljs-built_in">super</span>(scope, id, props);

    <span class="hljs-comment">// The code that defines your stack goes here</span>

    const myFunction<span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> lambda.Function(<span class="hljs-built_in">this</span>, <span class="hljs-string">'LambdaHandler'</span>, {
      runtime: lambda.Runtime.NODEJS_14_X,    <span class="hljs-comment">// execution environment</span>
      code: lambda.Code.fromAsset(<span class="hljs-string">'lambda'</span>),  <span class="hljs-comment">// code loaded from "lambda" directory</span>
      handler: <span class="hljs-string">'index.handler'</span>                <span class="hljs-comment">// file is "index", function is "handler"</span>
    });

    const fnUrl <span class="hljs-operator">=</span> myFunction.addFunctionUrl({  <span class="hljs-comment">// your function url</span>
      authType: lambda.FunctionUrlAuthType.NONE,
    });

    <span class="hljs-keyword">new</span> CfnOutput(<span class="hljs-built_in">this</span>, <span class="hljs-string">'TheUrl'</span>, {
      <span class="hljs-built_in">value</span>: fnUrl.url,
    });
  }
}
</code></pre><p>At the root of your project, (next to lib and bin), create a lambda folder and inside it, an index.js file</p>
<pre><code><span class="hljs-comment"># at the root of your project</span>
mkdir <span class="hljs-keyword">lambda</span>
cd <span class="hljs-keyword">lambda</span>
touch index.js
</code></pre><p>lambda/index.js (let's render some html ! )</p>
<pre><code>exports.handler <span class="hljs-operator">=</span> async <span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"><span class="hljs-keyword">event</span></span>) </span>{
    console.log(<span class="hljs-string">"request:"</span>, JSON.stringify(<span class="hljs-function"><span class="hljs-keyword">event</span>, <span class="hljs-title">undefined</span>, 2))</span>;
    const body <span class="hljs-operator">=</span> <span class="hljs-string">'&lt;html&gt;&lt;head&gt;&lt;title&gt;HTML from Lambda URL&lt;/title&gt;&lt;/head&gt;'</span> <span class="hljs-operator">+</span> 
    <span class="hljs-string">'&lt;body&gt;&lt;h1&gt;Hello you ! This is served by a Lambda function URL&lt;/h1&gt;&lt;/body&gt;&lt;/html&gt;'</span>
    <span class="hljs-keyword">return</span> {
      statusCode: <span class="hljs-number">200</span>,
      headers: { <span class="hljs-string">"Content-Type"</span>: <span class="hljs-string">"text/html"</span> },
      body
    };
  };
</code></pre><p>Everything is ready ! Now let's deploy</p>
<pre><code>❯ cdk deploy

✨  Synthesis time: <span class="hljs-number">14</span>.84s

LambdaUrlStack: deploying...
[<span class="hljs-number">0</span><span class="hljs-operator">%</span>] start: Publishing XXXXXXXXXXXXXXXXX:current_account<span class="hljs-operator">-</span>current_region
[<span class="hljs-number">0</span><span class="hljs-operator">%</span>] start: Publishing XXXXXXXXXXXXXXXXX:current_account<span class="hljs-operator">-</span>current_region
[<span class="hljs-number">50</span><span class="hljs-operator">%</span>] success: Published XXXXXXXXXXXXXXXXX:current_account<span class="hljs-operator">-</span>current_region
[<span class="hljs-number">100</span><span class="hljs-operator">%</span>] success: Published :XXXXXXXXXXXXXXXXXcurrent_account<span class="hljs-operator">-</span>current_region
LambdaUrlStack: creating CloudFormation changeset...

 ✅  LambdaUrlStack

✨  Deployment time: <span class="hljs-number">45</span>.96s

Outputs:
LambdaUrlStack.TheUrl <span class="hljs-operator">=</span> https:<span class="hljs-comment">//XXXXXXXXXXXXXXXXX.lambda-url.us-east-1.on.aws/</span>
Stack ARN: XXXXXXXXX:stack<span class="hljs-operator">/</span>LambdaUrlStack<span class="hljs-operator">/</span>XXXXXXXX

✨  Total time: <span class="hljs-number">60</span>.79s
</code></pre><p>You can find the code on this <a target="_blank" href="https://github.com/SoniaisMad/lambda-function-url-example-cdk">repository</a></p>
<h3 id="heading-on-the-console">On the console</h3>
<p>Go to Lambda , you should see the one you just created.</p>
<p>Click on it, and you should see your function URL (see capture)</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1653569410742/NbAAGwFv6.png" alt="Capture d’écran 2022-05-26 à 14.45.18.png" /></p>
<h3 id="heading-test-our-lambda">Test our lambda</h3>
<p>Copy the function URL and paste in your browser, hit enter and you should see this : </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1653569532759/5oRxWTB0f.png" alt="Capture d’écran 2022-05-26 à 14.51.18.png" /></p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>Congrats ! You know now how to use Function URLs for Lambda.</p>
<p>To go further : <a target="_blank" href="https://docs.aws.amazon.com/lambda/latest/dg/lambda-urls.html">AWS Documentation</a></p>
<p>See you in the next one :) </p>
]]></content:encoded></item><item><title><![CDATA[How to integrate Typeform into your React application]]></title><description><![CDATA[Introduction
Recently, i was working with a React application and i wanted to integrate a form that i created on Typeform.This article is explaining how you can manage that using the React Embed Typeform library.  
Create a Next.js application
Let's ...]]></description><link>https://crunchcrunch.me/how-to-integrate-typeform-into-your-react-application</link><guid isPermaLink="true">https://crunchcrunch.me/how-to-integrate-typeform-into-your-react-application</guid><category><![CDATA[React]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Tue, 01 Mar 2022 16:50:32 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/ldDmTgf89gU/upload/v1646153381133/oAJ6gCJR28.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-introduction">Introduction</h3>
<p>Recently, i was working with a React application and i wanted to integrate a form that i created on Typeform.<br />This article is explaining how you can manage that using the React Embed Typeform library.  </p>
<h3 id="heading-create-a-nextjs-application">Create a Next.js application</h3>
<p>Let's create a Next.js app </p>
<pre><code>yarn <span class="hljs-keyword">create</span> <span class="hljs-keyword">next</span>-app
</code></pre><p>and start the server</p>
<pre><code><span class="hljs-attribute">yarn</span> dev
</code></pre><p>We will edit the pages/index.js page this way.</p>
<pre><code><span class="hljs-keyword">import</span> <span class="hljs-title">Head</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'next/head'</span>
<span class="hljs-title"><span class="hljs-keyword">import</span></span> <span class="hljs-title">Image</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'next/image'</span>
<span class="hljs-title"><span class="hljs-keyword">import</span></span> <span class="hljs-title">styles</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'../styles/Home.module.css'</span>

<span class="hljs-title">export</span> <span class="hljs-title">default</span> <span class="hljs-title"><span class="hljs-keyword">function</span></span> <span class="hljs-title">Home</span>() {
  <span class="hljs-title"><span class="hljs-keyword">return</span></span> (
    <span class="hljs-operator">&lt;</span><span class="hljs-title">div</span> <span class="hljs-title">className</span><span class="hljs-operator">=</span>{<span class="hljs-title">styles</span>.<span class="hljs-title">container</span>}<span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span><span class="hljs-title">Head</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-title">title</span><span class="hljs-operator">&gt;</span><span class="hljs-title">Create</span> <span class="hljs-title">Next</span> <span class="hljs-title">App</span><span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">title</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-title">meta</span> <span class="hljs-title">name</span><span class="hljs-operator">=</span><span class="hljs-string">"description"</span> <span class="hljs-title">content</span><span class="hljs-operator">=</span><span class="hljs-string">"Generated by create next app"</span> <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-title">link</span> <span class="hljs-title">rel</span><span class="hljs-operator">=</span><span class="hljs-string">"icon"</span> <span class="hljs-title">href</span><span class="hljs-operator">=</span><span class="hljs-string">"/favicon.ico"</span> <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">Head</span><span class="hljs-operator">&gt;</span>

      <span class="hljs-operator">&lt;</span><span class="hljs-title">main</span> <span class="hljs-title">className</span><span class="hljs-operator">=</span>{<span class="hljs-title">styles</span>.<span class="hljs-title">main</span>}<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-title">h1</span> <span class="hljs-title">className</span><span class="hljs-operator">=</span>{<span class="hljs-title">styles</span>.<span class="hljs-title">title</span>}<span class="hljs-operator">&gt;</span>
          <span class="hljs-title">Welcome</span> <span class="hljs-title">to</span> <span class="hljs-operator">&lt;</span><span class="hljs-title">a</span> <span class="hljs-title">href</span><span class="hljs-operator">=</span><span class="hljs-string">"https://nextjs.org"</span><span class="hljs-operator">&gt;</span><span class="hljs-title">Next</span>.<span class="hljs-title">js</span><span class="hljs-operator">!</span><span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">a</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">h1</span><span class="hljs-operator">&gt;</span>

        <span class="hljs-operator">&lt;</span><span class="hljs-title">p</span> <span class="hljs-title">className</span><span class="hljs-operator">=</span>{<span class="hljs-title">styles</span>.<span class="hljs-title">description</span>}<span class="hljs-operator">&gt;</span>
          <span class="hljs-title">Get</span> <span class="hljs-title">started</span> <span class="hljs-title">by</span> <span class="hljs-title">editing</span>{<span class="hljs-string">' '</span>}
          <span class="hljs-operator">&lt;</span><span class="hljs-title">code</span> <span class="hljs-title">className</span><span class="hljs-operator">=</span>{<span class="hljs-title">styles</span>.<span class="hljs-title">code</span>}<span class="hljs-operator">&gt;</span><span class="hljs-title">pages</span><span class="hljs-operator">/</span><span class="hljs-title">index</span>.<span class="hljs-title">js</span><span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">code</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">p</span><span class="hljs-operator">&gt;</span>

        <span class="hljs-operator">&lt;</span><span class="hljs-title">div</span> <span class="hljs-title">className</span><span class="hljs-operator">=</span>{<span class="hljs-title">styles</span>.<span class="hljs-title">grid</span>}<span class="hljs-operator">&gt;</span>
          <span class="hljs-title">Your</span> <span class="hljs-title">Typeform</span> <span class="hljs-title">will</span> <span class="hljs-title">be</span> <span class="hljs-title">here</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">div</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">main</span><span class="hljs-operator">&gt;</span>

      <span class="hljs-operator">&lt;</span><span class="hljs-title">footer</span> <span class="hljs-title">className</span><span class="hljs-operator">=</span>{<span class="hljs-title">styles</span>.<span class="hljs-title">footer</span>}<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-title">a</span>
          <span class="hljs-title">href</span><span class="hljs-operator">=</span><span class="hljs-string">"https://vercel.com?utm_source=create-next-app&amp;utm_medium=default-template&amp;utm_campaign=create-next-app"</span>
          <span class="hljs-title">target</span><span class="hljs-operator">=</span><span class="hljs-string">"_blank"</span>
          <span class="hljs-title">rel</span><span class="hljs-operator">=</span><span class="hljs-string">"noopener noreferrer"</span>
        <span class="hljs-operator">&gt;</span>
          <span class="hljs-title">Powered</span> <span class="hljs-title">by</span>{<span class="hljs-string">' '</span>}
          <span class="hljs-operator">&lt;</span><span class="hljs-title">span</span> <span class="hljs-title">className</span><span class="hljs-operator">=</span>{<span class="hljs-title">styles</span>.<span class="hljs-title">logo</span>}<span class="hljs-operator">&gt;</span>
            <span class="hljs-operator">&lt;</span><span class="hljs-title">Image</span> <span class="hljs-title">src</span><span class="hljs-operator">=</span><span class="hljs-string">"/vercel.svg"</span> <span class="hljs-title">alt</span><span class="hljs-operator">=</span><span class="hljs-string">"Vercel Logo"</span> <span class="hljs-title">width</span><span class="hljs-operator">=</span>{72} <span class="hljs-title">height</span><span class="hljs-operator">=</span>{16} <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
          <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">span</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">a</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">footer</span><span class="hljs-operator">&gt;</span>
    <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">div</span><span class="hljs-operator">&gt;</span>
  )
}
</code></pre><p>You will see something like this in your browser : </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1646141039526/NrSndDkjd.png" alt="Screenshot from 2022-03-01 14-23-09.png" /></p>
<h3 id="heading-embed-typeform">Embed typeform</h3>
<p>Typeform has an official <a target="_blank" href="https://developer.typeform.com/embed/react/">React Embed Library</a></p>
<pre><code><span class="hljs-attribute">yarn</span> add <span class="hljs-variable">@typeform</span>/embed-react
</code></pre><p>And use it inside your component like this </p>
<pre><code><span class="hljs-keyword">import</span> { <span class="hljs-title">Widget</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'@typeform/embed-react'</span>

<span class="hljs-title">const</span> <span class="hljs-title">MyComponent</span> <span class="hljs-operator">=</span> () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
  <span class="hljs-title"><span class="hljs-keyword">return</span></span> <span class="hljs-operator">&lt;</span><span class="hljs-title">Widget</span> <span class="hljs-title">id</span><span class="hljs-operator">=</span><span class="hljs-string">"&lt;form-id&gt;"</span> <span class="hljs-title">style</span><span class="hljs-operator">=</span>{{ <span class="hljs-title">width</span>: <span class="hljs-string">'50%'</span> }} <span class="hljs-title">className</span><span class="hljs-operator">=</span><span class="hljs-string">"my-form"</span> <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
}
</code></pre><h3 id="heading-integrate-your-form-into-your-application">Integrate your form into your application</h3>
<p>Let's add our form into our index page </p>
<p>The first thing you need is your form id : </p>
<p>You can find  from the public URL of your form </p>
<pre><code>form.typeform.com/to<span class="hljs-operator">/</span><span class="hljs-operator">&lt;</span>form<span class="hljs-operator">-</span>id<span class="hljs-operator">&gt;</span>
</code></pre><p>Let's modify our index.js to add our Widget.</p>
<pre><code><span class="hljs-keyword">import</span> { <span class="hljs-title">Widget</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'@typeform/embed-react'</span>

<span class="hljs-title">export</span> <span class="hljs-title">default</span> <span class="hljs-title"><span class="hljs-keyword">function</span></span> <span class="hljs-title">Home</span>() {
  <span class="hljs-title"><span class="hljs-keyword">return</span></span> (
    <span class="hljs-operator">&lt;</span><span class="hljs-title">div</span> <span class="hljs-title">className</span><span class="hljs-operator">=</span>{<span class="hljs-title">styles</span>.<span class="hljs-title">container</span>}<span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span><span class="hljs-title">Head</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-title">title</span><span class="hljs-operator">&gt;</span><span class="hljs-title">Create</span> <span class="hljs-title">Next</span> <span class="hljs-title">App</span><span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">title</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-title">meta</span> <span class="hljs-title">name</span><span class="hljs-operator">=</span><span class="hljs-string">"description"</span> <span class="hljs-title">content</span><span class="hljs-operator">=</span><span class="hljs-string">"Generated by create next app"</span> <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-title">link</span> <span class="hljs-title">rel</span><span class="hljs-operator">=</span><span class="hljs-string">"icon"</span> <span class="hljs-title">href</span><span class="hljs-operator">=</span><span class="hljs-string">"/favicon.ico"</span> <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">Head</span><span class="hljs-operator">&gt;</span>

      <span class="hljs-operator">&lt;</span><span class="hljs-title">main</span> <span class="hljs-title">className</span><span class="hljs-operator">=</span>{<span class="hljs-title">styles</span>.<span class="hljs-title">main</span>}<span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-title">h1</span> <span class="hljs-title">className</span><span class="hljs-operator">=</span>{<span class="hljs-title">styles</span>.<span class="hljs-title">title</span>}<span class="hljs-operator">&gt;</span>
          <span class="hljs-title">Welcome</span> <span class="hljs-title">to</span> <span class="hljs-operator">&lt;</span><span class="hljs-title">a</span> <span class="hljs-title">href</span><span class="hljs-operator">=</span><span class="hljs-string">"https://nextjs.org"</span><span class="hljs-operator">&gt;</span><span class="hljs-title">Next</span>.<span class="hljs-title">js</span><span class="hljs-operator">!</span><span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">a</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">h1</span><span class="hljs-operator">&gt;</span>

        <span class="hljs-operator">&lt;</span><span class="hljs-title">p</span> <span class="hljs-title">className</span><span class="hljs-operator">=</span>{<span class="hljs-title">styles</span>.<span class="hljs-title">description</span>}<span class="hljs-operator">&gt;</span>
          <span class="hljs-title">Get</span> <span class="hljs-title">started</span> <span class="hljs-title">by</span> <span class="hljs-title">editing</span>{<span class="hljs-string">' '</span>}
          <span class="hljs-operator">&lt;</span><span class="hljs-title">code</span> <span class="hljs-title">className</span><span class="hljs-operator">=</span>{<span class="hljs-title">styles</span>.<span class="hljs-title">code</span>}<span class="hljs-operator">&gt;</span><span class="hljs-title">pages</span><span class="hljs-operator">/</span><span class="hljs-title">index</span>.<span class="hljs-title">js</span><span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">code</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">p</span><span class="hljs-operator">&gt;</span>

        <span class="hljs-operator">&lt;</span><span class="hljs-title">div</span> <span class="hljs-title">className</span><span class="hljs-operator">=</span>{<span class="hljs-title">styles</span>.<span class="hljs-title">grid</span>}<span class="hljs-operator">&gt;</span>
           <span class="hljs-comment">// ------ here is your Widget ------------</span>
          <span class="hljs-operator">&lt;</span><span class="hljs-title">Widget</span> <span class="hljs-title">id</span><span class="hljs-operator">=</span><span class="hljs-string">"&lt;form-id&gt;"</span> <span class="hljs-title">style</span><span class="hljs-operator">=</span>{{ <span class="hljs-title">width</span>: <span class="hljs-string">'500px'</span>, <span class="hljs-title">height</span>: <span class="hljs-string">"400px"</span> }} <span class="hljs-title">className</span><span class="hljs-operator">=</span><span class="hljs-string">"my-form"</span> <span class="hljs-operator">/</span><span class="hljs-operator">&gt;</span>
        <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">div</span><span class="hljs-operator">&gt;</span>
      <span class="hljs-operator">&lt;</span><span class="hljs-operator">/</span><span class="hljs-title">main</span><span class="hljs-operator">&gt;</span>
...
</code></pre><p>NB : don't forget to replace the  with your form id ! </p>
<p>You should see your Widget now in your application</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1646142710105/fEt_7LBNZ.png" alt="Screenshot from 2022-03-01 14-51-33.png" /></p>
<p>You can also choose to display your Typeform with a Popover or a Slidertab if you like.
Check the documentation to see all the display options.</p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>As you can see, it's pretty easy ! 
If you have any questions, feel free to ask in the comments ! </p>
<p>See you in the next one ! </p>
]]></content:encoded></item><item><title><![CDATA[[ Devops : Back to Basics ] : The Network Layer]]></title><description><![CDATA[This article is part of a serie called [ Devops : Back to Basics ] where i document what i'm learning on my journey to become a Devops Engineer from my current position as a Backend Engineer.
The Network Layer
On a local area network or LAN, nodes ca...]]></description><link>https://crunchcrunch.me/devops-back-to-basics-the-network-layer</link><guid isPermaLink="true">https://crunchcrunch.me/devops-back-to-basics-the-network-layer</guid><category><![CDATA[Devops]]></category><category><![CDATA[network]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Fri, 11 Feb 2022 15:42:25 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/SwVkmowt7qA/upload/v1644511468698/z6W5oBMFI.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><em>This article is part of a serie called [ Devops : Back to Basics ] where i document what i'm learning on my journey to become a Devops Engineer from my current position as a Backend Engineer.</em></p>
<h3 id="heading-the-network-layer">The Network Layer</h3>
<p>On a local area network or LAN, nodes can communicate with each other through their physical MAC addresses. This works well on small scale because switches can quickly learn the MAC addresses connected to each other ports to forward transmissions appropriately. But MAC addressing isn't a scheme that scales well, every single network interface on the planet has a unique MAC address and they aren't ordered in any systematic way. There is no way of knowing where on the planet a certain MAC address might be at any one point in time, so it's not ideal for communicating across distances. </p>
<h4 id="heading-ip-addresses">IP addresses</h4>
<p>IP addresses are a 32 bit long numbers made up of four octets, and each octet is normally described in decimal numbers. 
This format is known as dotted decimal notation. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1644510564820/R1mlFn6mD.png" alt="ipv4-5bdcc3d4c9e77c0051c98cca.png" /></p>
<p>The important thing to know for now is that IP addresses are distributed in large sections to various organizations and companies instead of being determined by hardware vendors.
For example IBM, which owns every single IP that has the number 9 as the first octet. 
At a very high level, this means that if an Internet router needs to figure out where to send a data packet intended for the IP address 9.0.0.1, that router only has to know to get it to one of IBMs routers.  </p>
<p>You can find <a target="_blank" href="https://en.wikipedia.org/wiki/List_of_assigned_/8_IPv4_address_blocks#:~:text=List%20of%20assigned%20/8%20blocks%20to%20the%20regional%20Internet%20registries%5Bedit%5D">here</a> the list of how ip adresses are distributed.</p>
<p>It's important to understand that IP addresses belong to the networks, not the devices attached to those networks. 
So your laptop will always have the same MAC address no matter where you use it, but it will have a different IP address assigned to it at your work than it would when you're at home.</p>
<h4 id="heading-ip-address-classes">IP address classes</h4>
<p>IP addresses can be split into two sections, the network ID and the host ID.<br />Earlier we mentioned that IBM owns all IP addresses that have a nine as the value of the first octet in an IP address.<br />If we take an example IP address of 9.100.100.100, the network ID would be the first octet, and the host ID would be the second, third and fourth octets. 
The address class system is a way of defining how the global IP address space is split up. </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1639152239644/lVWI2vD4F.png" alt="ip adress class@2x.png" /></p>
<h4 id="heading-routers">Routers</h4>
<p>Routers are networking devices operating at layer 3 or a network layer of the OSI model.<br />They are responsible for receiving, analyzing, and forwarding data packets among the connected computer networks.<br />When a data packet arrives, the router inspects the destination address, consults its routing tables to decide the optimal route and then transfers the packet along this route</p>
<h4 id="heading-arp-address-resolution-protocol">ARP (address resolution protocol)</h4>
<p>Address Resolution Protocol (ARP) is a protocol that connects an ever-changing Internet Protocol (IP) address to a fixed physical machine address, also known as a media access control (MAC) address, in a local-area network (LAN). </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1644510899902/m8InmRHK5.webp" alt="1625683953964.webp" /></p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>That's it !</p>
<p>Don't hesitate to comment to point out some mistakes or make some precisions.</p>
<p>As i said in the beginning, i am still studying these concepts :)</p>
<p>See you in the next one ! 🤖🤖🤖</p>
]]></content:encoded></item><item><title><![CDATA[Use AWS Chatbot to run your AWS Lambda function from Slack]]></title><description><![CDATA[In this tutorial we are going to use AWS Chatbot to run a Lambda function remotely from Slack.
To create the lambda and the SNS Topic to talk to the Bot, we are going to use CDK.
To setup the ChatBot we'll do it on the console.
The Lambda
Let's creat...]]></description><link>https://crunchcrunch.me/use-aws-chatbot-to-run-your-aws-lambda-function-from-slack</link><guid isPermaLink="true">https://crunchcrunch.me/use-aws-chatbot-to-run-your-aws-lambda-function-from-slack</guid><category><![CDATA[AWS]]></category><category><![CDATA[chatbot]]></category><category><![CDATA[aws lambda]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Tue, 01 Feb 2022 12:51:09 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/2EJCSULRwC8/upload/v1643719959808/QX8JbKEYU.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In this tutorial we are going to use AWS Chatbot to run a Lambda function remotely from Slack.</p>
<p>To create the lambda and the SNS Topic to talk to the Bot, we are going to use CDK.
To setup the ChatBot we'll do it on the console.</p>
<h3 id="heading-the-lambda">The Lambda</h3>
<p>Let's create our project</p>
<pre><code>mkdir chatBotLambda
cd chatBotLambda
npm <span class="hljs-keyword">init</span> -y
</code></pre><p>Then install CDK and the packages we need</p>
<pre><code>npm install <span class="hljs-operator">-</span>g aws<span class="hljs-operator">-</span>cdk
npm i @aws<span class="hljs-operator">-</span>cdk<span class="hljs-operator">/</span>aws<span class="hljs-operator">-</span>lambda
npm i @aws<span class="hljs-operator">-</span>cdk<span class="hljs-operator">/</span>aws<span class="hljs-operator">-</span>sns
npm i @aws<span class="hljs-operator">-</span>cdk<span class="hljs-operator">/</span>aws<span class="hljs-operator">-</span>sns<span class="hljs-operator">-</span>subscriptions
mkdir cdk<span class="hljs-operator">-</span>folder
cdk init app <span class="hljs-operator">-</span><span class="hljs-operator">-</span>language typescript
</code></pre><p>Open the file lib/cdk-folder-stack.ts</p>
<pre><code><span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">cdk</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'@aws-cdk/core'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">lambda</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'@aws-cdk/aws-lambda'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">sns</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'@aws-cdk/aws-sns'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">subs</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'@aws-cdk/aws-sns-subscriptions'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">cloudwatch</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'@aws-cdk/aws-cloudwatch'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">path</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'path'</span>;

export class CdkFolderStack extends cdk.Stack {
  <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params">scope: cdk.Construct, id: <span class="hljs-keyword">string</span>, props?: cdk.StackProps</span>) </span>{
    <span class="hljs-built_in">super</span>(scope, id, props);

    <span class="hljs-comment">// sns topic</span>
    const topic <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> sns.Topic(<span class="hljs-built_in">this</span>, <span class="hljs-string">'my-lambda-notifications'</span>, {
      displayName: <span class="hljs-string">'My SNS topic'</span>,
    });
    topic.addSubscription(<span class="hljs-keyword">new</span> subscriptions.EmailSubscription(<span class="hljs-string">"your-email@adress"</span>);

    <span class="hljs-comment">// lambda function</span>
    const myLambdaFunction <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> lambda.Function(<span class="hljs-built_in">this</span>, <span class="hljs-string">'my-lambda'</span>, {
      runtime: lambda.Runtime.NODEJS_14_X,
      memorySize: <span class="hljs-number">256</span>,
      timeout: cdk.Duration.seconds(<span class="hljs-number">60</span>),
      handler: <span class="hljs-string">'index.main'</span>,
      code: lambda.Code.fromAsset(path.join(__dirname, <span class="hljs-string">'/../app/my-lambda/'</span>)),
    });
  }
}
</code></pre><p>Lambda part
Now the lambda code</p>
<pre><code><span class="hljs-keyword">mkdir</span> app
cd app
<span class="hljs-keyword">mkdir</span> <span class="hljs-keyword">my</span>-lambda
cd <span class="hljs-keyword">my</span>-lambda
npm init -<span class="hljs-keyword">y</span> 
touch index.js
</code></pre><p>Very simple code for the lambda : </p>
<pre><code>exports.main <span class="hljs-operator">=</span> async (<span class="hljs-function"><span class="hljs-keyword">event</span>) =&gt; </span>{
        console.log(<span class="hljs-string">'Hello ChatBot'</span>);
};
</code></pre><p>Bootstrap and deploy </p>
<pre><code><span class="hljs-attribute">cdk</span> bootstrap
⏳  Bootstrapping environment aws://XXXXXXXXXXXXX/us-east-1...
 ✅  Environment aws://XXXXXXXXXXXXXX/us-east-1 bootstrapped (<span class="hljs-literal">no</span> changes).

cdk deploy
</code></pre><p>Now we have our lambda, next step, the ChatBot</p>
<h3 id="heading-the-chatbot">The ChatBot</h3>
<p>Open the AWS Chatbot console.</p>
<p>Under Configure a Chat client choose Slack, and then choose Configure.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1643719785618/wDoYY2_en.png" alt="Capture d’écran 2022-02-01 à 13.49.18.png" /></p>
<p>In the upper right corner, choose the dropdown list, and then choose the Slack workspace that you want to use with AWS Chatbot and choose Allow.</p>
<p>Choose Configure new channel.</p>
<p>Under Configuration details, for Name, enter AWSChatBot.</p>
<p>Under Channel type, choose Private.</p>
<p>Navigate to Slack and create a private channel by choosing the + button to the right of Channels.</p>
<p>Choose Create a channel.</p>
<p>Name the channel AWSChatBot and make it private then hit create.</p>
<p>When prompted to add people, choose x.</p>
<p>Navigate back to the AWS Chatbot console and enter the private channel ID.</p>
<p>Define the IAM permissions that the chatbot uses for messaging your Slack chat room:</p>
<p>For Role name, enter AWSChatBotRole.</p>
<p>For Policy Templates, select Read-only command permissions and Lambda-invoke command permissions.</p>
<p>In the SNS topics section, choose the appropriate AWS Region under Region.</p>
<p>Under Topics, select the AWSChatBotNotifications topic.</p>
<p>Choose Configure.</p>
<p>Your ChatBot is ready ! </p>
<h3 id="heading-make-them-work-together">Make them work together</h3>
<p>Invite yout AWS Chatbot to your channel by doing the following in Slack : </p>
<pre><code><span class="hljs-meta">@AWS</span>
</code></pre><p>hit enter and choose invite to the channel.</p>
<p>Enter the following command in Slack</p>
<pre><code>@aws lambda invoke <span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-function"><span class="hljs-keyword">function</span>-<span class="hljs-title">name</span> &lt;<span class="hljs-title">your</span>-<span class="hljs-title"><span class="hljs-keyword">function</span></span>-<span class="hljs-title">name</span>&gt; --<span class="hljs-title">region</span> &lt;<span class="hljs-title">your</span> <span class="hljs-title">region</span>&gt;</span>
</code></pre><p>The output should be : </p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1643647324925/4_4gSRQnB.png" alt="Capture d’écran 2022-01-31 à 17.40.52.png" /></p>
<p>Congrats ! You can now invoke your lambda from Slack ! 
Pretty convenient to test out some stuff ! </p>
<h3 id="heading-clean-up">Clean up</h3>
<p>To destroy the lambda and the SNS topic : </p>
<pre><code><span class="hljs-attribute">cdk</span> destroy
</code></pre><p>To delete the chatbot : </p>
<ul>
<li><p>Open the AWS Chatbot console.</p>
</li>
<li><p>Choose Slack.</p>
</li>
<li><p>Choose the radio button next to the channel you created and then choose Delete.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Unit tests with AWS CDK]]></title><description><![CDATA[Lately, I have been using the AWS CDK a lot to set up infrastructure on AWS, and the fact that they have integrated solutions to unit test the code is really great.
I will show how to use the CDK assertions (aws-cdk-lib/assertions) library to write u...]]></description><link>https://crunchcrunch.me/unit-tests-with-aws-cdk</link><guid isPermaLink="true">https://crunchcrunch.me/unit-tests-with-aws-cdk</guid><category><![CDATA[AWS]]></category><category><![CDATA[aws-cdk]]></category><dc:creator><![CDATA[Sonia Manoubi]]></dc:creator><pubDate>Mon, 27 Dec 2021 11:49:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/_zsL306fDck/upload/v1640277972578/KoB-MzAvr.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Lately, I have been using the AWS CDK a lot to set up infrastructure on AWS, and the fact that they have integrated solutions to unit test the code is really great.</p>
<p>I will show how to use the CDK assertions (aws-cdk-lib/assertions) library to write unit tests about your stacks. The library (aws-cdk-lib/assertions) contains several helper functions for writing unit and integration tests.</p>
<h3 id="heading-create-a-project">Create a project</h3>
<pre><code>mkdir unitTestCdk
cd unitTestCdk
cdk init app <span class="hljs-operator">-</span><span class="hljs-operator">-</span>language typescript
yarn add @aws<span class="hljs-operator">-</span>cdk<span class="hljs-operator">/</span><span class="hljs-built_in">assert</span>
</code></pre><p>The command generates an empty stack.</p>
<p>Go to lib/unit_test_cdk-stack.ts</p>
<pre><code><span class="hljs-keyword">import</span> { Stack, StackProps } <span class="hljs-keyword">from</span> <span class="hljs-string">'aws-cdk-lib'</span>;
<span class="hljs-keyword">import</span> { Construct } <span class="hljs-keyword">from</span> <span class="hljs-string">'constructs'</span>;

<span class="hljs-keyword">export</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">UnitTestCdkStack</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Stack</span> </span>{
  <span class="hljs-keyword">constructor</span>(scope: Construct, id: string, props?: StackProps) {
    <span class="hljs-built_in">super</span>(scope, id, props);

    <span class="hljs-comment">// The code that defines your stack goes here</span>
       👇👇👇👇👇👇👇👇

  }
}
</code></pre><p>Let's write a test for that.</p>
<p>Go to test/unit_test_cdk.test.ts, you will already have the structure to write your first test.
Let's write our test : </p>
<pre><code><span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">cdk</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'aws-cdk-lib'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">'@aws-cdk/assert/jest'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">UnitTestCdk</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'../lib/unit_test_cdk-stack'</span>;

test(<span class="hljs-string">'Empty stack'</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    const app <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> cdk.App();

    const stack <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> UnitTestCdk.UnitTestCdkStack(app, <span class="hljs-string">'MyTestStack'</span>);

    expect(stack).not.toHaveResource(<span class="hljs-string">'AWS::SQS::Queue'</span>);
});
</code></pre><p>Let's run our test</p>
<pre><code><span class="hljs-string">yarn</span> <span class="hljs-string">test</span>

<span class="hljs-string">$</span> <span class="hljs-string">jest</span>
 <span class="hljs-string">PASS</span>  <span class="hljs-string">test/unit_test_cdk.test.ts</span> <span class="hljs-string">(7.442</span> <span class="hljs-string">s)</span>
  <span class="hljs-string">✓</span> <span class="hljs-string">Empty</span> <span class="hljs-string">stack</span> <span class="hljs-string">(25</span> <span class="hljs-string">ms)</span>

<span class="hljs-attr">Test Suites:</span> <span class="hljs-number">1</span> <span class="hljs-string">passed,</span> <span class="hljs-number">1</span> <span class="hljs-string">total</span>
<span class="hljs-attr">Tests:</span>       <span class="hljs-number">1</span> <span class="hljs-string">passed,</span> <span class="hljs-number">1</span> <span class="hljs-string">total</span>
<span class="hljs-attr">Snapshots:</span>   <span class="hljs-number">0</span> <span class="hljs-string">total</span>
<span class="hljs-attr">Time:</span>        <span class="hljs-number">7.488</span> <span class="hljs-string">s</span>
<span class="hljs-string">Ran</span> <span class="hljs-string">all</span> <span class="hljs-string">test</span> <span class="hljs-string">suites.</span>
<span class="hljs-string">✨</span>  <span class="hljs-string">Done</span> <span class="hljs-string">in</span> <span class="hljs-number">8.</span><span class="hljs-string">23s.</span>
</code></pre><p>Great ! Now let's add a resource , and update our test</p>
<h3 id="heading-with-a-sqs-queue">With a SQS queue</h3>
<pre><code><span class="hljs-keyword">import</span> { <span class="hljs-title">Stack</span>, <span class="hljs-title">StackProps</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'aws-cdk-lib'</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title">Construct</span> } <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'constructs'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">sqs</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'aws-cdk-lib/aws-sqs'</span>;

export class UnitTestCdkStack extends Stack {
  <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params">scope: Construct, id: <span class="hljs-keyword">string</span>, props?: StackProps</span>) </span>{
    <span class="hljs-built_in">super</span>(scope, id, props);

    <span class="hljs-comment">// The code that defines your stack goes here</span>

    <span class="hljs-comment">// example resource</span>
    const queue <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> sqs.Queue(<span class="hljs-built_in">this</span>, <span class="hljs-string">'UnitTestCdkQueue'</span>, {
      queueName: <span class="hljs-string">"sqs-test"</span>
    });
  }
}
</code></pre><p>Let's update our test now</p>
<pre><code><span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">cdk</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'aws-cdk-lib'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">'@aws-cdk/assert/jest'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">UnitTestCdk</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'../lib/unit_test_cdk-stack'</span>;

test(<span class="hljs-string">'stack with SQS queue'</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    const app <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> cdk.App();

    const stack <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> UnitTestCdk.UnitTestCdkStack(app, <span class="hljs-string">'MyTestStack'</span>);

    expect(stack).toHaveResource(<span class="hljs-string">'AWS::SQS::Queue'</span>);
});
</code></pre><p>And run the test </p>
<pre><code><span class="hljs-string">yarn</span> <span class="hljs-string">test</span>

 <span class="hljs-string">PASS</span>  <span class="hljs-string">test/unit_test_cdk.test.ts</span> <span class="hljs-string">(10.276</span> <span class="hljs-string">s)</span>
  <span class="hljs-string">✓</span> <span class="hljs-string">stack</span> <span class="hljs-string">with</span> <span class="hljs-string">SQS</span> <span class="hljs-string">queue</span> <span class="hljs-string">(29</span> <span class="hljs-string">ms)</span>

<span class="hljs-attr">Test Suites:</span> <span class="hljs-number">1</span> <span class="hljs-string">passed,</span> <span class="hljs-number">1</span> <span class="hljs-string">total</span>
<span class="hljs-attr">Tests:</span>       <span class="hljs-number">1</span> <span class="hljs-string">passed,</span> <span class="hljs-number">1</span> <span class="hljs-string">total</span>
<span class="hljs-attr">Snapshots:</span>   <span class="hljs-number">0</span> <span class="hljs-string">total</span>
<span class="hljs-attr">Time:</span>        <span class="hljs-number">10.346</span> <span class="hljs-string">s</span>
<span class="hljs-string">Ran</span> <span class="hljs-string">all</span> <span class="hljs-string">test</span> <span class="hljs-string">suites.</span>
<span class="hljs-string">✨</span>  <span class="hljs-string">Done</span> <span class="hljs-string">in</span> <span class="hljs-number">11.</span><span class="hljs-string">81s.</span>
</code></pre><p>We can even test check the queue name : </p>
<pre><code><span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">cdk</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'aws-cdk-lib'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">'@aws-cdk/assert/jest'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-operator">*</span> <span class="hljs-title"><span class="hljs-keyword">as</span></span> <span class="hljs-title">UnitTestCdk</span> <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">'../lib/unit_test_cdk-stack'</span>;

test(<span class="hljs-string">'stack with SQS queue'</span>, () <span class="hljs-operator">=</span><span class="hljs-operator">&gt;</span> {
    const app <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> cdk.App();

    const stack <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> UnitTestCdk.UnitTestCdkStack(app, <span class="hljs-string">'MyTestStack'</span>);

    expect(stack).toHaveResource(<span class="hljs-string">'AWS::SQS::Queue'</span>, {
        QueueName: <span class="hljs-string">'sqs-test'</span>
     });
});
</code></pre><p>You can look further in the  <a target="_blank" href="https://docs.aws.amazon.com/cdk/v2/guide/testing.html">AWS Documentation</a>  to find helpers to test your stack the way you need it.</p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>Now, you know how to unit test your infrastructure created with AWS CDK ! </p>
<p>If you have any questions, feel free to ask in the comments, i'll do my best to answer ! </p>
<p>See you next in the next one ! 🤖 </p>
]]></content:encoded></item></channel></rss>