1. Answers
  2. Deploy Wazuh Docker Image on AWS EC2 with TypeScript

How do I deploy the wazuh/wazuh:latest docker image on AWS EC2 with TypeScript?

In this guide, we will deploy the wazuh/wazuh:latest Docker image on an AWS EC2 instance using Pulumi and TypeScript. We will create an EC2 instance, install Docker, and run the Wazuh container.

Key Points

  • Create an EC2 instance on AWS.
  • Install Docker on the EC2 instance.
  • Run the wazuh/wazuh:latest Docker image on the instance.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

// Create a new security group for the EC2 instance
const securityGroup = new aws.ec2.SecurityGroup("wazuh-sg", {
    description: "Allow HTTP and SSH",
    ingress: [
        { protocol: "tcp", fromPort: 22, toPort: 22, cidrBlocks: ["0.0.0.0/0"] },
        { protocol: "tcp", fromPort: 80, toPort: 80, cidrBlocks: ["0.0.0.0/0"] },
    ],
});

// Create an EC2 instance
const server = new aws.ec2.Instance("wazuh-server", {
    instanceType: "t2.micro",
    ami: "ami-0c55b159cbfafe1f0", // Amazon Linux 2 AMI
    securityGroups: [securityGroup.name],
    userData: `#!/bin/bash
    sudo yum update -y
    sudo amazon-linux-extras install docker -y
    sudo service docker start
    sudo usermod -a -G docker ec2-user
    sudo docker run -d -p 80:55000 wazuh/wazuh:latest
    `,
    tags: {
        Name: "wazuh-server",
    },
});

// Export the public IP of the instance
export const publicIp = server.publicIp;
export const publicHostName = server.publicDns;

Summary

In this guide, we created an AWS EC2 instance, installed Docker, and deployed the wazuh/wazuh:latest Docker image. The instance is configured to allow HTTP and SSH access, and the Wazuh container is running and accessible on port 80.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up