<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mike Ng</title>
    <description>The latest articles on DEV Community by Mike Ng (@mikeng_io).</description>
    <link>https://dev.to/mikeng_io</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F468988%2F632113ae-c317-4d8d-bbcb-3b0657b9eeca.jpg</url>
      <title>DEV Community: Mike Ng</title>
      <link>https://dev.to/mikeng_io</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mikeng_io"/>
    <language>en</language>
    <item>
      <title>Signing Ethereum and Tron transaction with AWS KMS Key</title>
      <dc:creator>Mike Ng</dc:creator>
      <pubDate>Tue, 18 Mar 2025 11:11:05 +0000</pubDate>
      <link>https://dev.to/aws-builders/introducing-the-aws-kms-signer-library-secure-blockchain-transactions-with-ease-1n5f</link>
      <guid>https://dev.to/aws-builders/introducing-the-aws-kms-signer-library-secure-blockchain-transactions-with-ease-1n5f</guid>
      <description>&lt;p&gt;In the world of blockchain technology, managing cryptographic keys securely is crucial. The AWS KMS Signer library offers a robust solution for developers looking to integrate secure signing operations into their Ethereum and Tron applications. This article introduces the AWS KMS Signer library, highlighting its features, usage, and the benefits of using AWS Key Management Service (KMS).&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the AWS KMS Signer Library?
&lt;/h2&gt;

&lt;p&gt;The AWS KMS Signer library is a powerful tool that leverages AWS KMS to perform cryptographic signing operations. It is designed to enhance the security of blockchain applications by managing keys within the secure AWS environment, eliminating the need to handle plaintext private keys directly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Features:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Secure Key Management&lt;/strong&gt;: Utilizes AWS KMS to securely manage cryptographic keys.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Multi-Network Support&lt;/strong&gt;: Compatible with both Ethereum and Tron networks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TypeScript Support&lt;/strong&gt;: Provides type definitions for enhanced development experience.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Comprehensive Test Suite&lt;/strong&gt;: Ensures reliability and security through extensive testing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why Use AWS KMS?
&lt;/h2&gt;

&lt;p&gt;AWS KMS provides a secure and resilient infrastructure for key management, ensuring that your keys are protected by hardware security modules (HSMs) that are FIPS 140-2 validated. Here are some key benefits:&lt;/p&gt;

&lt;h3&gt;
  
  
  Security
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Key Isolation&lt;/strong&gt;: Keys are stored in a secure environment and never leave the AWS infrastructure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Access Control&lt;/strong&gt;: Fine-grained permissions can be set using AWS Identity and Access Management (IAM) policies, allowing you to control who can access and use your keys.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Compliance and Auditing
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Audit Logging&lt;/strong&gt;: AWS CloudTrail provides logs of all key usage, helping you meet compliance and regulatory requirements. This ensures transparency and accountability in key management operations.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Scalability
&lt;/h3&gt;

&lt;p&gt;AWS KMS is designed to scale with your needs, making it suitable for large-scale blockchain applications that require robust key management solutions.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the AWS KMS Signer Works
&lt;/h2&gt;

&lt;p&gt;The library interacts with AWS KMS to perform signing operations, ensuring that private keys never leave the secure AWS environment. This integration provides a seamless experience for developers, allowing them to focus on building their applications without worrying about key management.&lt;/p&gt;

&lt;h3&gt;
  
  
  Usage Example:
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Ethereum Signer Usage:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;EthereumSigner&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;aws-kms-signer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Initialize the signer&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;signer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;EthereumSigner&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;keyId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;your-kms-key-id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;rpcUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;any-ethereum-rpc-endpoint&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Get the Ethereum address&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;signer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getAddress&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Sign a message&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello, Ethereum!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;signature&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;signer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;signMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Sign a transaction&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;transaction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;to&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0x...&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ethers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parseEther&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;0.1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="c1"&gt;// ... other transaction parameters&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;signedTx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;signer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;signTransaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Tron Signer Usage:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;TronSigner&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;aws-kms-signer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Initialize the signer&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;signer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;TronSigner&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;keyId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;your-kms-key-id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// Get the Tron address&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;address&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;signer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getAddress&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Sign a message (TIP-191 compliant)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello, Tron!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;signature&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;signer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;signMessageV2&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Sign a transaction&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;transaction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;tronWeb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;transactionBuilder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendTrx&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;recipient-address&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="mi"&gt;1000000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// amount in SUN&lt;/span&gt;
  &lt;span class="nx"&gt;address&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;signedTx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;signer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;signTransaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Benefits of Using the AWS KMS Signer
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Security
&lt;/h3&gt;

&lt;p&gt;By using AWS KMS, the AWS KMS Signer ensures that private keys are never exposed, significantly reducing the risk of unauthorized access.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ease of Use
&lt;/h3&gt;

&lt;p&gt;The library is designed to be easy to integrate into existing blockchain applications, providing a seamless experience for developers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Flexibility
&lt;/h3&gt;

&lt;p&gt;With support for both Ethereum and Tron networks, the AWS KMS Signer is versatile and can be used in a variety of blockchain applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The AWS KMS Signer library offers a secure, scalable, and easy-to-use solution for managing cryptographic keys in blockchain applications. By leveraging AWS KMS, developers can enhance the security of their applications while simplifying key management. Whether you're building on Ethereum or Tron, the AWS KMS Signer provides the tools you need to protect your assets and ensure compliance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Additional Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/MikletNg/aws-kms-signer-nodejs" rel="noopener noreferrer"&gt;AWS KMS Signer GitHub Repository&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.npmjs.com/package/aws-kms-signer-nodejs" rel="noopener noreferrer"&gt;AWS KMS Signer NPM Package&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/kms/" rel="noopener noreferrer"&gt;AWS KMS Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/kms/latest/developerguide/getting-started.html" rel="noopener noreferrer"&gt;Getting Started with AWS KMS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>ethereum</category>
      <category>kms</category>
      <category>typescript</category>
    </item>
    <item>
      <title>How to send large batch transaction to EVM-based blockchain network using AWS serverless service</title>
      <dc:creator>Mike Ng</dc:creator>
      <pubDate>Thu, 30 Mar 2023 19:03:43 +0000</pubDate>
      <link>https://dev.to/aws-builders/how-to-send-large-batch-transaction-to-evm-based-blockchain-network-using-aws-serverless-service-2akn</link>
      <guid>https://dev.to/aws-builders/how-to-send-large-batch-transaction-to-evm-based-blockchain-network-using-aws-serverless-service-2akn</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This article is just a start, there will be more updates coming up like extracting the &lt;code&gt;gas fee&lt;/code&gt; wallet to a separate wallet either using the private key in Secrets Manager or the KMS key and also setting up multiple workers for the minting process in the ERC721 smart contract. Which enables a higher volume of transactions executions performance.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This article illustrates sending a large batch of transactions from a single EOA on any EVM-based Blockchain network.&lt;/p&gt;

&lt;p&gt;The entire solution used Lambda, Step Function, and SQS.  At first, this solution will keep it simple as possible and continue to update.&lt;/p&gt;

&lt;p&gt;To get started on this solution, please make sure you have development experience with any EVM-based blockchain network and ether.js.&lt;/p&gt;

&lt;p&gt;As we all know, when sending transactions on any EVM-based blockchain will have a &lt;code&gt;nonce&lt;/code&gt;. The nonce is the number of transactions sent from a given address which acts as a one-time code that prevents replay attacks or double-spending.&lt;/p&gt;

&lt;p&gt;This means when sending batch transactions in an EVM-based blockchain, you have to wait until the recently sent transaction has been mined in the latest block, then you can get the latest &lt;code&gt;nonce&lt;/code&gt; and send the next transaction.&lt;/p&gt;

&lt;p&gt;If the application is sending the transaction in a synchronous manner, the overall performance and execution experience will be very poor. This means the entire transaction-sending process must be refactored and extracted to become an asynchronous process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fymxgu7raoqf3jsaxk2uy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fymxgu7raoqf3jsaxk2uy.png" alt=" " width="561" height="105"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This solution has used a FIFO queue to ensure the transaction has been sent in an absolute order for processing. The example ERC-721 has been written to demonstrate large batch or minting process execution in Lambda function.&lt;/p&gt;

&lt;p&gt;For the detail configuration and setting you can see directly in the CDK &lt;a href="https://github.com/MikletNg/aws-evm-tx-fifo" rel="noopener noreferrer"&gt;Github repository&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>web3</category>
      <category>blockchain</category>
      <category>ethereum</category>
    </item>
    <item>
      <title>How to implement serverless to optimize the flexibility of your architecture on AWS</title>
      <dc:creator>Mike Ng</dc:creator>
      <pubDate>Fri, 26 Aug 2022 09:23:23 +0000</pubDate>
      <link>https://dev.to/aws-builders/how-to-implement-serverless-to-optimize-the-flexibility-of-your-architecture-on-aws-403e</link>
      <guid>https://dev.to/aws-builders/how-to-implement-serverless-to-optimize-the-flexibility-of-your-architecture-on-aws-403e</guid>
      <description>&lt;p&gt;In this blog post, we will explore what serverless is and how to implement it on AWS.&lt;/p&gt;

&lt;p&gt;Serverless is a new way of building and deploying applications. It's a way to build applications that have no servers, but still benefit from the scale and reliability of AWS. This can be useful for your team if you want to build more modularized apps with less overhead, or if you want to scale up quickly without worrying about managing infrastructure or configuring an operating system for each instance of your application.&lt;/p&gt;

&lt;p&gt;If serverless sounds like something that would help you, read on!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is serverless?
&lt;/h2&gt;

&lt;p&gt;Serverless is an architecture that abstracts the infrastructure layer. It’s similar to virtual machines or containers in that it offers a higher level of abstraction, where you don’t need to explicitly manage resources on your own.&lt;/p&gt;

&lt;p&gt;Serverless allows developers and organizations to build applications quickly without having to worry about managing servers or infrastructure.&lt;/p&gt;

&lt;p&gt;Serverless architectures are an abstraction of the infrastructure layer similar to virtual machines or containers. They provide a way to build software without having to worry about how it gets deployed, scaled and managed. The concept has been around for years but only recently has become popular due to its simplicity and flexibility.&lt;/p&gt;

&lt;p&gt;Serverless applications can be thought of as any type of application that does not have its own infrastructure (i.e., servers). This includes web apps, mobile apps, IoT devices and more—allowing you greater control over your application’s resources than you would have otherwise had with classic cloud hosting options like AWS Lambda or Azure Functions."&lt;/p&gt;

&lt;h2&gt;
  
  
  They offer a higher level of abstraction, where you don’t need to explicitly manage resources.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You don't need to manage infrastructure.&lt;/li&gt;
&lt;li&gt;You don't need to manage scaling.&lt;/li&gt;
&lt;li&gt;You don't need to manage security.&lt;/li&gt;
&lt;li&gt;You don't need to manage operations, monitoring and logs (or backups).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead, you simply focus on writing code.&lt;/p&gt;

&lt;p&gt;You can focus on writing code instead of managing infrastructure.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You don't have to worry about scaling.&lt;/li&gt;
&lt;li&gt;You don't have to worry about infrastructure, operations and capacity planning, or cost management.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why go serverless?
&lt;/h2&gt;

&lt;p&gt;There are many reasons to consider going serverless. Some of the main advantages include:&lt;/p&gt;

&lt;p&gt;Manage infrastructure and operations independently of your application code. You can scale up or down your infrastructure without changing the code and without affecting end users. This gives you more flexibility in how much compute resources you need and when they need it, which helps reduce costs by eliminating wasted hardware or idle servers, as well as simplifies management through fewer monitoring points (no need for an internal IT team). You also get better visibility into resource utilization so that if there's an issue with one part of the system it won't take down another part at the same time—allowing you to fix them separately instead of having everything come down at once!&lt;/p&gt;

&lt;p&gt;Reduce time-to-market by building faster than before; save money on cloud hosting fees because AWS already exists within most organizations' existing infrastructures; give developers access directly from their favorite development toolset rather than forcing them onto something new - which means less learning curve &amp;amp; faster adoption rates across teams."&lt;/p&gt;

&lt;h2&gt;
  
  
  Serverless can help you build scalable applications quickly without thinking about infrastructure and operations.
&lt;/h2&gt;

&lt;p&gt;You can focus on building your application instead of managing infrastructure. You can scale your application without having to worry about infrastructure. And finally, you can deploy your application without having to worry about infrastructure&lt;/p&gt;

&lt;h2&gt;
  
  
  Ever increasing demand for scalability and availability has made it difficult to estimate the future capacity needs of your application infrastructure.
&lt;/h2&gt;

&lt;p&gt;Serverless computing has been gaining popularity as a cost-effective way to scale your application infrastructure. As it becomes easier and more affordable, more and more organizations are adopting serverless architectures to meet their business needs.&lt;/p&gt;

&lt;p&gt;Serverless computing can help you improve scalability, security and time-to-market by removing the burden of managing servers from your organization. Here’s why:&lt;/p&gt;

&lt;p&gt;It decreases operational costs by eliminating the need for manual maintenance or updates in the cloud management layer of an application stack (e.g., AWS Lambda). This allows you to focus on building new features instead of maintaining old ones; however, there will still be some extra work involved because you may need someone else (or several people) within the company who understands how things work under “the hood” when using these tools in order for them not only maintain but also grow faster than possible without this kind approach.*&lt;/p&gt;

&lt;h2&gt;
  
  
  Serverless allows you to run code on as-needed basis without worrying about scaling.
&lt;/h2&gt;

&lt;p&gt;You only pay for what you use and therefor have more control over the development process.&lt;/p&gt;

&lt;p&gt;It's a great solution when it comes to building applications with microservices or any other kind of distributed architecture where multiple teams are working in different locations.&lt;/p&gt;

&lt;h2&gt;
  
  
  This means that you only pay for what you use, which leads to significant cost savings compared to maintaining a fixed scale or overprovisioning resources.
&lt;/h2&gt;

&lt;p&gt;You don't need to worry about infrastructure: Serverless allows you to focus on developing your products without having to manage the underlying infrastructure. This frees up time and energy so that it can be spent on other things like building features and adding value for customers.&lt;/p&gt;

&lt;h2&gt;
  
  
  The ability to deploy functionality without worrying about infrastructure can improve time-to-market significantly by letting developers focus on building the applications instead of deploying them.
&lt;/h2&gt;

&lt;p&gt;This is because serverless allows you to run code on as-needed basis without worrying about scaling, so if your application grows in size and complexity, there's no need for additional servers or servers that scale up with more load.&lt;/p&gt;

&lt;p&gt;Serverless technology also has a significant impact on security because it enables developers to focus on building their applications rather than managing their own infrastructure.&lt;/p&gt;

&lt;h2&gt;
  
  
  It also gives more control over the development process as teams can make fast deployments without being dependent on other groups such as IT operations or networking teams.
&lt;/h2&gt;

&lt;p&gt;Serverless architecture also gives more control over the development process as teams can make fast deployments without being dependent on other groups such as IT operations or networking teams. In addition, it allows developers to focus on building applications instead of deploying them, which makes it easier for them to build faster and more scalable solutions.&lt;/p&gt;

&lt;h2&gt;
  
  
  There are many cloud providers who support serverless solutions - such as AWS, Azure, Google Cloud Platform and IBM Cloud Functions - with AWS Lambda being the key player in this area currently because of its mature implementation and strong user community.
&lt;/h2&gt;

&lt;p&gt;However there are still some details that need to be taken into account when choosing a provider: firstly it’s important to understand which features you need to implement on your own platform. Secondly what type of data will be used by your application? Lastly how will you manage costs based on demand?&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope this blog post has given you an understanding of serverless and how it can help you build scalable applications. If you’re interested in learning more about serverless architectures and how they can be implemented on AWS, check out our other blog posts on the topic:&lt;/p&gt;

</description>
      <category>aws</category>
      <category>serverless</category>
    </item>
    <item>
      <title>How Web3.0 technology influent traditional Cloud industry</title>
      <dc:creator>Mike Ng</dc:creator>
      <pubDate>Fri, 26 Aug 2022 09:13:00 +0000</pubDate>
      <link>https://dev.to/aws-builders/how-web30-technology-influent-traditional-cloud-industry-3896</link>
      <guid>https://dev.to/aws-builders/how-web30-technology-influent-traditional-cloud-industry-3896</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Web3.0 technology is a disruptive concept that has the potential to revolutionize the way people use technology and interact with data. Since its inception, Web3.0 has gained widespread popularity, mainly due to its ability to provide decentralized solutions over centralized implementations of cloud computing. Web3.0 can be applied in many industries such as healthcare, finance, media and entertainment (M&amp;amp;E), transportation, education etc which will help businesses create smart solutions using cutting edge tools like AI technologies and blockchain platforms like Ethereum or Neo network&lt;/p&gt;

&lt;h2&gt;
  
  
  Web3.0 Technology Introduction
&lt;/h2&gt;

&lt;p&gt;Web3.0 is a network of decentralized applications (dApps) and protocols that are not controlled by any single entity. It allows users to interact with each other through their computers instead of having to go through an intermediary company or individual.&lt;/p&gt;

&lt;p&gt;The first step in understanding web3 is understanding what it isn't: It's not about blockchain technology, which we'll talk about later in this article. Instead, web3 refers to a new way people can build software applications; you could think of it as "web 2.0" for the next generation—and yes, that's still happening!&lt;/p&gt;

&lt;h2&gt;
  
  
  Potential Influence Area of Web3.0 Technology
&lt;/h2&gt;

&lt;p&gt;Web3.0 is a new generation of cloud computing technology that integrates blockchain and cloud computing, which could be the future direction of digital transformation.&lt;/p&gt;

&lt;p&gt;Web3.0 technology has been developed by companies such as Amazon, Google and Microsoft to provide users with better services through decentralized networks (distributed ledgers) in exchange for fees paid by consumers or businesses using their services through smart contracts on Ethereum’s blockchain network (ETH).&lt;/p&gt;

&lt;h2&gt;
  
  
  How Web3.0 technology influent traditional Cloud industry
&lt;/h2&gt;

&lt;p&gt;The cloud has been around for a while now, but it is still an industry that is growing and expanding. However, there are many ways in which Web3.0 technology can help to improve the traditional Cloud industry by providing better solutions for businesses of all sizes.&lt;/p&gt;

&lt;p&gt;In this article we will look at how Web3.0 technology influent traditional Cloud industry and its future potentials for growth as well as how it can improve upon current practices within the industry&lt;/p&gt;

&lt;p&gt;Web3.0 could finally empower the adoption of cloud computing&lt;/p&gt;

&lt;p&gt;Web3.0 technology could be the key to unlocking the potential of cloud computing.&lt;/p&gt;

&lt;p&gt;The emergence of Web3.0 is already changing how we interact with technology and with each other, but it's not just about replacing existing companies or products; it also has the potential to empower new ways of doing business—and this time around, they're more than just nice-to-have luxuries.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Although cloud computing has been around for years, it is still in its infancy. Web3.0 technology, on the other hand, has been around for a few years and is already being used by many organizations as a way to make their computing needs more flexible and efficient. With Web3.0 technology becoming more popular each day and having the potential to change how we interact with information on our devices, hopefully we can soon see how these two technologies work together to bring even more innovation into our lives!&lt;/p&gt;

</description>
      <category>cloud</category>
      <category>web3</category>
    </item>
    <item>
      <title>How to secure and ensure the internet-facing application load balancer only allow traffic from CloudFront?</title>
      <dc:creator>Mike Ng</dc:creator>
      <pubDate>Sat, 07 Nov 2020 19:33:23 +0000</pubDate>
      <link>https://dev.to/aws-builders/how-to-ensure-your-internet-facing-application-load-balancer-only-allow-traffic-from-cloudfront-56a</link>
      <guid>https://dev.to/aws-builders/how-to-ensure-your-internet-facing-application-load-balancer-only-allow-traffic-from-cloudfront-56a</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwxqojwrnurv7bo52n835.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwxqojwrnurv7bo52n835.png" alt="Architecture Diagram" width="800" height="303"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For every created internet-facing load balancer in AWS, they will have a public hostname. At most of the situation, a CloudFront distribution will be sitting in front of the load balancer for caching the static content and accelerate the delivery. And a WAF web ACL may create along and associate with the CloudFront distribution to provide application security. Or some Lambda@Edge function may create for customizing the content on the CloudFront distribution.&lt;/p&gt;

&lt;p&gt;And now the problem is if the public hostname of the load balancer was exposed to the internet, the hacker on the internet can be bypassing the web ACL at the CloudFront distribution to attack the application. The only way is to only allow inbound traffics from CloudFront distribution.&lt;/p&gt;

&lt;p&gt;To achieve this restriction, for every inbound request, the CloudFront distribution will insert a custom header &lt;code&gt;X_Request_From_CloudFront&lt;/code&gt; with a hash value when the request passing through, and next forward to the load balancer. And the load balancer will have another associated WAF web ACL, to validate if the &lt;code&gt;X_Request_From_CloudFront&lt;/code&gt; custom header exists and matching the hash value. The web ACL will reject the request if the custom header not exists or the value does not match.&lt;/p&gt;

&lt;p&gt;In order to hide the custom header &lt;code&gt;X_Request_From_CloudFront&lt;/code&gt;, and its hash value from the client-side and server-side, the 'Drop invalid header fields' is required to enable in the load balancer. &lt;/p&gt;

&lt;p&gt;According to the document, &lt;a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#load-balancer-attributes" rel="noopener noreferrer"&gt;Load balancer attributes&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Indicates whether HTTP headers with header fields that are not valid are removed by the load balancer (true), or routed to targets (false). The default is false. Elastic Load Balancing requires that message header names contain only alphanumeric characters and hyphens.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Since the custom header &lt;code&gt;X_Request_From_CloudFront&lt;/code&gt; contains underscores, the load balancer will consider it as an invalid header and remove the custom header and its value when the request passing through, which means it only exists in the request between the CloudFront distribution and the load balancer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/add-origin-custom-headers.html#add-origin-custom-headers-configure" rel="noopener noreferrer"&gt;Adding Custom Headers to Origin Requests&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancers.html#load-balancer-attributes" rel="noopener noreferrer"&gt;Load balancer attributes&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloudfront</category>
      <category>security</category>
    </item>
    <item>
      <title>Best Practices for Running Container WordPress on AWS (ECS, EFS, RDS, ELB) using CDK</title>
      <dc:creator>Mike Ng</dc:creator>
      <pubDate>Sat, 31 Oct 2020 16:20:49 +0000</pubDate>
      <link>https://dev.to/aws-builders/best-practices-for-running-wordpress-on-aws-using-cdk-aj9</link>
      <guid>https://dev.to/aws-builders/best-practices-for-running-wordpress-on-aws-using-cdk-aj9</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Recently I helped my friend migrate her eShop from WordPress.com to AWS. Since her business keeps growing to a larger scale,  a third-party eCommerce hosting platform no longer fulfill her business needed. To satisfy the growing business needed, I have designed, transform, enhance, and migrated to a high availability architecture on AWS for her WordPress eCommerce business.&lt;/p&gt;

&lt;p&gt;To reuse the infrastructure and simplify the deployment, I have used the AWS CDK. Cloud Development Kit is an open-source framework to define the infrastructure as code using familiar programming languages. I have written the infrastructure using Typescript, and after the CDK is compiled, a CloudFormation template will be generated and deployed on AWS.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/cdk/" rel="noopener noreferrer"&gt;AWS CDK&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;During the migration, I find out there aren't many documents or information about hosting WordPress on AWS, that why I written this blog post.&lt;/p&gt;




&lt;p&gt;In this post, I won't explain so much about what those AWS services usage and benefit, and only talk about the reason I use it and how I configure it. This blog post is more like the extension of the &lt;a href="https://aws.amazon.com/tw/blogs/architecture/wordpress-best-practices-on-aws/" rel="noopener noreferrer"&gt;WordPress: Best Practices on AWS&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6m7wkfv6ja74hly1i002.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6m7wkfv6ja74hly1i002.png" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AWS has provided the Best Practice document &lt;a href="https://aws.amazon.com/tw/blogs/architecture/wordpress-best-practices-on-aws/" rel="noopener noreferrer"&gt;WordPress: Best Practices on AWS&lt;/a&gt;. After I read the document, I find out it still has a lot of room for improvement, it also doesn't take care much of the security of the WordPress application.&lt;/p&gt;

&lt;p&gt;Other than that, there are some interesting ideas I have implement in this solution. Like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;How to secure the admin page(wp-admin)?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How to ensure your internet-facing application load balancer only allow traffic from CloudFront?&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;❗❗❗&lt;strong&gt;Please ensure you have read through the Best Practice document before reading down.&lt;/strong&gt;❗❗❗&lt;/p&gt;

&lt;p&gt;❗❗❗&lt;strong&gt;Also please ensure you have the basic knowledge of AWS cloud or any other cloud providers.&lt;/strong&gt;❗❗❗&lt;/p&gt;




&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fniqpcxkepv6aio914jul.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fniqpcxkepv6aio914jul.png" alt="Architecture Diagram" width="800" height="287"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Basically, the architecture can split it into multiple pillars:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Compute&lt;/li&gt;
&lt;li&gt;Storage&lt;/li&gt;
&lt;li&gt;Database&lt;/li&gt;
&lt;li&gt;Cache&lt;/li&gt;
&lt;li&gt;CDN&lt;/li&gt;
&lt;li&gt;DNS&lt;/li&gt;
&lt;li&gt;Security&lt;/li&gt;
&lt;li&gt;Backup&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Compute
&lt;/h3&gt;

&lt;p&gt;According to the best practice document, it used EC2 for hosting. But I choose to containerize the WordPress application because Docker runs above OS, which means the container is much lighter than an EC2 instance, also the startup speed is faster and uses much less memory.&lt;/p&gt;

&lt;p&gt;For running a containerized application on AWS, I am hosting the WordPress application using Fargate on ECS.  By using Fargate, I don't need to provision and manage any EC2 servers, only need to allocate how much vCPUs and memory for the container. And recently, &lt;a href="https://aws.amazon.com/blogs/aws/aws-fargate-spot-now-generally-available/" rel="noopener noreferrer"&gt;Fargate Spot&lt;/a&gt; has announced which can take up to 70% of cost-saving.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/fargate/" rel="noopener noreferrer"&gt;AWS Fargate&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This architecture takes advantage of the capability of the capacity provider on the ECS cluster, using the default capacity provider strategy to launch multiple tasks mixed with Fargate and Fargate Spot launch type. For the first 3 tasks in the services, it will be standard Fargate launch type, which provided a baseline for high availability. And for the rest of the tasks, for every 3 tasks, 2 tasks will be the regular Fargate launch type, and the rest 1 task will be the Fargate Spot launch type. This strategy which can provide &lt;strong&gt;high availability service but also maximize the cost optimization.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To distribute the incoming request to the multiple running containers equally, an application load balancer has been set up. I have chosen to use the LOR algorithm instead of the regular round-robin algorithm. Because the round-robin algorithm will not consider the capacity or utilization of the target containers, this led to over-utilization or under-utilization of the target containers when the request has long process times. Whit the LOR algorithm, now the application load balancer can router the requests to the least number of an outstanding request, which further reduces the response time and balanced the utilization for each container.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fct1zsbrzfkcqibg0996w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fct1zsbrzfkcqibg0996w.png" width="541" height="321"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are 3 containers for each task, Nginx, PHP FPM, and X-Ray daemon. The reason I choose Nginx instead of Apache is the plugin W3 Total Cache support set up the page caching on Nginx instead of the application level. The X-Ray daemon was created for the AWS X-Ray plugin in WordPress, the plugin which collects the performance and information of each request and sends it to AWS X-Ray through the daemon.&lt;/p&gt;

&lt;h3&gt;
  
  
  Storage
&lt;/h3&gt;

&lt;p&gt;WordPress is a stateful application, which means for each time you do some changes to the configuration, the files of WordPress will be changed. But Docker is a stateless service, which will lose all of it changes when every time you restart the container. If the WordPress application running in such an environment, its configuration will be lost when scale-in or scale-out events. To handle such a situation, I have used AWS EFS to store the WordPress application. EFS is a distributed file system, which means when every time the WordPress application file changed, the other running container will still using the same file instead of a local isolated file. Also, I have set up the lifecycle rule for the files where hasn't use over the past 90 days, to change the storage class to infrequent access, which to lower the cost.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/efs/" rel="noopener noreferrer"&gt;Amazon EFS&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The WordPress application has a lot of static files, like Javascript, CSS, images, videos, etc. Intending to lower the response time and the request counts to the WordPress application, I have used a plugin WP Offload Media to offload the static files to S3. This plugin will upload the newly created media to S3 whenever I upload any images or videos.&lt;/p&gt;

&lt;h3&gt;
  
  
  Database
&lt;/h3&gt;

&lt;p&gt;To start a WordPress application, a MySQL database is required. Amazon RDS is a managed database service, which means I don't need to take care of database setup, patching, and backup. RDS support multiple databases, Aurora is one supported database in RDS. Amazon Aurora is developed by AWS and it is a relational database with MySQL and Postgres-compatible, It provides 5-times faster than a regular MySQL database, and the security, availability, and reliability of commercial databases at 1/10th the cost.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/rds/" rel="noopener noreferrer"&gt;Amazon RDS&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Aurora has 2 types of database - Provisioned and Serverless. The provisioned cluster is a regular database cluster, a master node, and multiple read replica. Another type is Serverless and I have chosen to use Aurora Serverless to running the MySQL database because I am not sure what size of the node type should be used. The Aurora Serverless was a little different from the provisioned type, it simular to Fargate. I only need to allocate how many ACU it need on startup and the maximum ACU it can scale, it natively provides auto-scaling features according to the CPU usage and number of connections of the database. Also, the Aurora Serverless support auto-pause, when your database has zero activity for a period of time, the database will be closed, and the database will back online when there is an activity to the database. I have disabled the auto-pause features since when the database went sleep, it needs to take at least 30 seconds to back online.&lt;/p&gt;

&lt;p&gt;But be noticed! Aurora Serverless database divided into 3 layers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Proxy&lt;/li&gt;
&lt;li&gt;Compute&lt;/li&gt;
&lt;li&gt;Storage
Although the proxy and storage layer are multi-AZ, the compute layer was SINGLE-AZ, which means when your database went down at the compute layer, it takes more time to back online compare to the provisioned cluster.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/rds/aurora/" rel="noopener noreferrer"&gt;Amazon Aurora&lt;/a&gt;&lt;br&gt;
&lt;a href="https://aws.amazon.com/rds/aurora/serverless/" rel="noopener noreferrer"&gt;Amazon Aurora Serverless&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;IF YOUR REQUIRE FOR RUNNING A HIGH AVAILABILITY DATABASE, DO NOT USE AURORA SERVERLESS. AND PLEASE USE THE AURORA PROVISIONED CLUSTER.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Cache
&lt;/h3&gt;

&lt;p&gt;I have chosen Memcached as the in-memory cache storage instead of Redis. And using Amazon ElastiCache for running the Memcached cluster. Amazon ElastiCache is a fully managed in-memory data store compatible with Redis and Memcached, which means I don't need to take care of the setup and patching.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/elasticache/memcached/" rel="noopener noreferrer"&gt;Amazon ElastiCache for Memcached&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6quf9yoyqopumzbruro0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6quf9yoyqopumzbruro0.png" width="640" height="339"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Memcached has better performance than Redis, according to these 2 blog posts.&lt;br&gt;
&lt;a href="https://blog.kernl.us/2020/02/should-i-use-memcached-or-redis-for-wordpress-caching/" rel="noopener noreferrer"&gt;Should I use Memcached or Redis for WordPress caching?&lt;br&gt;
&lt;/a&gt; and &lt;a href="https://www.mtwebsol.com/redis-and-memcached-wordpress-cache-vps-cloud" rel="noopener noreferrer"&gt;Redis &amp;amp; Memcached Cache for WordPress on VPS or Cloud &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To reduce the response time and put the cache into Memcached from WordPress, I have installed W3 Total Cache in WordPress. This plugin can setup different cache like &lt;code&gt;Page Cache&lt;/code&gt;,  &lt;code&gt;Database Cache&lt;/code&gt;, &lt;code&gt;Object Cache&lt;/code&gt;, and &lt;code&gt;Fragment Cache&lt;/code&gt; into Memcached. As above mentioned, I am using Nginx for running the WordPress application, and the W3TC support setting up the &lt;code&gt;Page Cache&lt;/code&gt; at Nginx level instead of WordPress application, which means when a request comes in, the Nginx will first search for the Memcached for the page caching, if any cache hit, Nginx will return the hit page cache instead forward the request to PHP-FMP, which further reduce the response time.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://wordpress.org/plugins/w3-total-cache/" rel="noopener noreferrer"&gt;W3 Total Cache&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  CDN
&lt;/h3&gt;

&lt;p&gt;To further reduces the response time, a CloudFront distribution has set up in front of the application load balancer. The distribution will cache the static content or requests into the edge location around the globe. When any user browsing the WordPress application, if the requested content is hit at the edge location, the distribution will return the hit cache instead of forward the request to the servers. The edge locations are usually located around the user which provided the lowest latency and faster delivery speed.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/cloudfront/" rel="noopener noreferrer"&gt;Amazon CloudFront&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  DNS
&lt;/h3&gt;

&lt;p&gt;There are 2 hosted zones in Route 53, a public and a private. The public hosted zone will have multiple records including an alias A record of the WordPress and an alias A record of the static file of the CloudFront distributions.&lt;/p&gt;

&lt;p&gt;The private hosted zone is associated with the VPC and in the private hosted zone, multiple A records were created for the different AWS resources hostname, including the Aurora Serverless cluster, the EFS file system, the ElastiCache Memcached cluster, the Elasticseach domain, and the private application load balancer. It provides identical and memorizable names With these records to various created AWS resources.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/route53/" rel="noopener noreferrer"&gt;Amazon Route 53&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/hosted-zones-private.html" rel="noopener noreferrer"&gt;Working with private hosted zone&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Security
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Network Security
&lt;/h4&gt;

&lt;p&gt;Unlike the usual subnet division, the VPC is consists of 3 types of the subnet, &lt;code&gt;Public&lt;/code&gt;, &lt;code&gt;Private&lt;/code&gt;, and &lt;code&gt;Isolated&lt;/code&gt;. The first 2 types of subnets are the same as usual, the outbound-traffic in the &lt;code&gt;Public&lt;/code&gt; subnet route through internet gateway, the outbound-traffic in the &lt;code&gt;Private&lt;/code&gt; subnet route through NAT gateway. The traffic in the &lt;code&gt;Isolated&lt;/code&gt; subnet will not have any internet access and only have local routing accessibility, which can ensure the resources inside are absolutely safe and isolated away from the internet.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_Scenario2.html" rel="noopener noreferrer"&gt;VPC with public and private subnets (NAT)&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Also, a network access control list has been set up for the created VPC, which can ensure any traffics comes in are for browsing WordPress application.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/vpc/latest/userguide/vpc-network-acls.html" rel="noopener noreferrer"&gt;Network ACLs&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;
  
  
  Encryption
&lt;/h4&gt;

&lt;p&gt;To encrypt data in transit, both application load balancer and CloudFront distribution have set up using the signed TLS certificate in ACM. With the benefit of the L2 constructor in CDK, these TLS certificates will create in ACM also create DNS records in Route 53 hosted zone for validation. For further to restrict user must connect to WordPress application using HTTPS, both CloudFront distribution and application load balancer has set up redirect HTTP to HTTPS.&lt;/p&gt;

&lt;p&gt;For security consideration, all of the stored data will be encrypted using the AWS managed keys in AWS KMS. The AWS managed keys are fully managed by AWS including the rotation. The Aurora Serverless cluster, EFS file system, static and logging file bucket in the S3 bucket all are encrypted using different AWS managed keys in KMS.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/certificate-manager/" rel="noopener noreferrer"&gt;AWS Certificate Manager&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;
  
  
  Application Security
&lt;/h4&gt;

&lt;p&gt;To secure the WordPress application away from the common web exploits, web ACLs have been set up on the CloudFront distribution. For the web ACL on the CloudFront distribution, I have assigned multiple AWS managed rule groups, they are &lt;code&gt;CommonRuleSet&lt;/code&gt;, &lt;code&gt;KnownBadInputsRuleSet&lt;/code&gt;, &lt;code&gt;WordPressRuleSet&lt;/code&gt;, &lt;code&gt;PHPRuleSet&lt;/code&gt;, &lt;code&gt;SQLiRuleSet&lt;/code&gt;, and &lt;code&gt;AmazonIpReputationList&lt;/code&gt;, please be reminded, part of the rules in some of the rule groups has been excluded, otherwise, it will block most of the requests to your WordPress application. With the above rules groups, the web ACL now can provide general protection against a wide variety of common threats and vulnerabilities.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/waf/" rel="noopener noreferrer"&gt;AWS WAF&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/waf/latest/developerguide/aws-managed-rule-groups.html" rel="noopener noreferrer"&gt;AWS Managed Rules for AWS WAF&lt;br&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;
  
  
  DDoS Protection
&lt;/h4&gt;

&lt;p&gt;DDoS is the most popular attack over the internet, with AWS Shield it can provide always-on detection and automatic inline mitigations that minimize application downtime and latency. AWS Shield Standard is automatically enabled for the CloudFront distribution and Route 53 hosted zone, which can protect against all known infrastructure (Layer 3 &amp;amp; 4) attack.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/shield/" rel="noopener noreferrer"&gt;AWS Shield&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;
  
  
  Record and evaluate configuration
&lt;/h4&gt;

&lt;p&gt;AWS Config has enabled to record and evaluate the configuration of the created resource. Multiple managed rule in AWS Config has been configured. A tag &lt;code&gt;aws-config:cloudformation:stack-name&lt;/code&gt; will be associated with every created resource during the CDK deployment. And for every rule in AWS Config was set to use tag-based policy to record the tagged resources. If the AWS Config recorded any configuration changed and non-compliance to the changed configuration, it will send an email using SNS to the administrator to notify the non-compliance situation.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/config/" rel="noopener noreferrer"&gt;AWS Config&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4&gt;
  
  
  Advanced Security
&lt;/h4&gt;

&lt;p&gt;In the following section, I will talk about&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;How to ensure your internet-facing application load balancer only allow traffic from CloudFront?&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;How to secure the admin page(wp-admin)?&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  How to ensure your internet-facing application load balancer only allow traffic from CloudFront?
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwxqojwrnurv7bo52n835.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwxqojwrnurv7bo52n835.png" width="800" height="303"&gt;&lt;/a&gt;&lt;/p&gt;


&lt;div class="ltag__link"&gt;
  &lt;a href="/aws-builders" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__org__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F2794%2F88da75b6-aadd-4ea1-8083-ae2dfca8be94.png" alt="AWS Community Builders " width="350" height="350"&gt;
      &lt;div class="ltag__link__user__pic"&gt;
        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F468988%2F632113ae-c317-4d8d-bbcb-3b0657b9eeca.jpg" alt="" width="800" height="800"&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/aws-builders/how-to-ensure-your-internet-facing-application-load-balancer-only-allow-traffic-from-cloudfront-56a" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;How to secure and ensure the internet-facing application load balancer only allow traffic from CloudFront?&lt;/h2&gt;
      &lt;h3&gt;Mike Ng for AWS Community Builders  ・ Nov 7 '20&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#aws&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#cloudfront&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#security&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


&lt;p&gt;The value of the custom header will be defined during the CDK deployment, and it will be a base64 encoded domain name of the public hosted zone, the hash value will be the same at the CloudFront distribution and the associated WAF web ACL, else all requests will be blocked.&lt;/p&gt;

&lt;h4&gt;
  
  
  How to secure the admin page(wp-admin)?
&lt;/h4&gt;

&lt;p&gt;Anyone who has ever used WordPress will know &lt;code&gt;wp-admin&lt;/code&gt; is the admin page, which causes huge loopholes in web security, which allow hackers to use brute force cracking methods similar to unlimited loops to crack the admin password.&lt;/p&gt;

&lt;p&gt;There are 2 methods were implement to secure the admin page in the solution. The first is to add a whitelist IP addresses list, second is set up a client VPN to access the private application load balancer.&lt;/p&gt;

&lt;h5&gt;
  
  
  Whitelisting IP Address
&lt;/h5&gt;

&lt;p&gt;For the first method, the whitelist IP addresses list need to fill in before the CDK deploy. After deployment, an IP set will be created in WAF. The WAF web ACL associated with the application load balancer will check the inbound request that comes from the CloudFront distribution, will also validate the IP address of the request with the 'admin' prefix in the path. If any other IP addresses that not on the whitelist attempt to enter the admin page will be blocked.&lt;/p&gt;

&lt;p&gt;This should be the easiest way to protect the WordPress admin page, but it requires the end-user to have a static public IPV4 address. The whitelist needs to update whenever the IP address update or changes.&lt;/p&gt;

&lt;h5&gt;
  
  
  Using Client VPN
&lt;/h5&gt;

&lt;p&gt;For the second method, it should be the most secure, feasible, and flexible. AWS client VPN is a managed VPN client-based services that allow end-user to access the private or restricted resource on AWS or on-premise securely, and it can run on any OpenVPN-based client. An AWS client VPN will be created in the VPC, for every end-user who connected to this VPN will have internet access through NAT and access to the private resources. A private application load balancer has been created, and its created for the connected VPN end-user which allows access to the WordPress application including the admin page securely.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/vpn/latest/clientvpn-admin/what-is.html" rel="noopener noreferrer"&gt;AWS Client VPN&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Backup
&lt;/h3&gt;

&lt;p&gt;Although Aurora Serverless cluster the snapshot and back in RDS, AWS Backup is set up to manage backups across the AWS services that WordPress used, including the Aurora Serverless cluster and the EFS file system.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/backup/" rel="noopener noreferrer"&gt;AWS Backup&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Deployment
&lt;/h2&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/mikeng-io" rel="noopener noreferrer"&gt;
        mikeng-io
      &lt;/a&gt; / &lt;a href="https://github.com/mikeng-io/aws-serverless-wordpress" rel="noopener noreferrer"&gt;
        aws-serverless-wordpress
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;AWS Serverless WordPress&lt;/h1&gt;
&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Introduction&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;Please read the blog post for introduction and explanation
&lt;a href="https://dev.to/aws-builders/best-practices-for-running-wordpress-on-aws-using-cdk-aj9" rel="nofollow"&gt;Dev.to: Best Practices for Running WordPress on AWS using CDK&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;WordPress Plugin Used&lt;/h3&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;W3 Total Cache&lt;/li&gt;
&lt;li&gt;WP Offload Media Lite&lt;/li&gt;
&lt;li&gt;ElasticPress&lt;/li&gt;
&lt;li&gt;Multiple Domain&lt;/li&gt;
&lt;li&gt;HumanMade - AWS-XRay (Working on making it work...)&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Architecture Diagram&lt;/h2&gt;

&lt;/div&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/mikeng-io/aws-serverless-wordpress/doc/architecture-diagram-v2.png"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fmikeng-io%2Faws-serverless-wordpress%2Fdoc%2Farchitecture-diagram-v2.png" alt="Architecture Diagram"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Deployment - (To be update)&lt;/h2&gt;

&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Before getting started&lt;/h3&gt;

&lt;/div&gt;
&lt;p&gt;Please make sure you have/are&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Using bash&lt;/li&gt;
&lt;li&gt;Node.js installed&lt;/li&gt;
&lt;li&gt;NPM and Yarn installed&lt;/li&gt;
&lt;li&gt;Installed and running Docker&lt;/li&gt;
&lt;li&gt;Installed and configured AWS CLI&lt;/li&gt;
&lt;li&gt;Installed the latest version of AWS CDK CLI&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;Please be notice, this stack only can deploy into us-east-1&lt;/em&gt;
0. You should have a public hosted zone in Route 53&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Initialize the CDK project, run &lt;code&gt;make init&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Deploy the CDK Toolkit stack on to the target region, run &lt;code&gt;cdk bootstrap aws://AWS_ACCOUNT_ID/AWS_REGION --profile AWS_PROFILE_NAME&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Copy the &lt;code&gt;config.sample.toml&lt;/code&gt; and rename to &lt;code&gt;config.toml&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;make easy-rsa-init gen-cert import-cert&lt;/code&gt; to generate the certificate for the Client VPN&lt;/li&gt;
&lt;li&gt;Modify the…&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/mikeng-io/aws-serverless-wordpress" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>aws</category>
      <category>serverless</category>
      <category>wordpress</category>
      <category>cdk</category>
    </item>
  </channel>
</rss>
