Key takeaways:
Ansible automates tasks like provisioning and application deployment using modules via SSH.
Create a security group to limit traffic to public port 3000
.
Use a YAML playbook to define tasks for creating the security group and launching the EC2 instance.
The security group allows TCP communication on port 3000
with all outbound traffic permitted.
Launch an EC2 instance specifying AMI, instance type, and a user data script for setup.
The user data script updates packages, installs Node.js, clones a GitHub repository, and runs the Node.js app.
AWS credentials are needed to run the code, executed with Ansible commands.
The application can take up to 2 minutes to be accessible at the public IP on port 3000
.
Ansible is an open-source automation tool designed to streamline provisioning, configuration management, application deployment, and orchestration tasks. It connects nodes and deploys small programs called Ansible modules to execute tasks. These modules run over SSH (or alternative protocols if SSH is unavailable) and are removed once the tasks are completed.
In this Answer, we will create a security group and set up a React application on an EC2 instance, ensuring the instance’s security by using only public port 3000
.
We will examine the code, provision the infrastructure, and finally create the security group. After that, we’ll launch an EC2 instance to host the React application, configuring it by specifying its AMIAmazon Machine Image is a template that contains the software configuration, including the operating system and additional software, required to launch an instance in the AWS cloud., instance type, and storage, and attaching the previously created security group.
Here is an architecture diagram of the provisioned infrastructure.