1. Answers
  2. Setting up an AWS EC2 instance with Windows 2019, IIS, and .NET 4.7

How do I set up an AWS EC2 instance with Windows 2019, IIS, and .NET 4.7?

In this guide, we will set up an AWS EC2 instance running Windows Server 2019, install IIS (Internet Information Services), and configure .NET Framework 4.7. We will use Pulumi to define and deploy our infrastructure.

The following Pulumi program will:

  1. Create a new EC2 instance with Windows Server 2019.
  2. Use a user data script to install IIS and .NET Framework 4.7 on the instance.
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

// Define the size and type of the EC2 instance
const instanceType = "t2.micro";

// Use the latest Windows Server 2019 AMI
const ami = aws.ec2.getAmi({
    mostRecent: true,
    owners: ["amazon"],
    filters: [
        { name: "name", values: ["Windows_Server-2019-English-Full-Base-*"] },
    ],
}).then(ami => ami.id);

// Define the user data script to install IIS and .NET Framework 4.7
const userData = `    
<powershell>
Install-WindowsFeature -name Web-Server -IncludeManagementTools
Install-WindowsFeature -name Web-Asp-Net45
</powershell>
`;

// Create a new EC2 instance
const ec2Instance = new aws.ec2.Instance("windows2019-iis", {
    instanceType: instanceType,
    ami: ami,
    keyName: "your-key-pair-name", // Replace with your key pair name
    userData: userData,
    tags: {
        Name: "Windows2019-IIS",
    },
    vpcSecurityGroupIds: ["your-security-group-id"], // Replace with your security group ID
});

// Export the instance's public IP
export const publicIp = ec2Instance.publicIp;
export const publicDns = ec2Instance.publicDns;

Key Points

  • We defined an EC2 instance using the aws.ec2.Instance resource.
  • We used the latest Windows Server 2019 AMI from Amazon’s AMI catalog.
  • The userData script installs IIS and .NET Framework 4.7 on the instance.
  • The EC2 instance is tagged with a name and associated with a security group.
  • We exported the instance’s public IP and DNS name for easy access.

Summary

This Pulumi program sets up an AWS EC2 instance with Windows Server 2019, installs IIS, and configures .NET Framework 4.7. The instance is created using the latest Windows Server 2019 AMI, and a user data script is used to handle the installation of IIS and .NET. The instance’s public IP and DNS name are exported for easy access.

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