Installing a Windows Feature: IIS
Important
The AWS OpsWorks Stacks service reached end of life on May 26, 2024 and has been disabled for both new and existing customers.
We strongly recommend customers migrate their workloads to other solutions as soon as possible. If you have questions about migration, reach out to the AWS Support Team on AWS re:Post
Windows features are a set of optional system components, including the .NET frameworks and Internet Information Services (IIS). This topic describes how to implement a cookbook to install a commonly used feature, Internet Information Services (IIS).
Note
Installing a
Package shows how
to install software that comes in an installer package, such as an MSI file,
which you must download to the instance and run. IIS cookbooks
Running a Recipe on a Windows
Instance shows how to use a
powershell_script
resource to install a Windows feature. This
example shows an alternative approach: use the Chef Windows cookbook'swindows_feature
resource. This cookbook contains a set of resources
that use Deployment Image Servicing and Management
Note
Chef also has an IIS cookbook, which you can use to manage IIS. For more
information, see IIS
cookbook
To set up the cookbook
-
Go to the windows cookbook GitHub repository
and download the windows
cookbook.This example assumes that you will download the
windows
repository as a .zip file, but you can also clone the repository if you prefer. -
Go to the chef_handler cookbook GitHub repository
and download the chef-handler
cookbook.The
windows
cookbook depends onchef_handler
; you won't be using it directly. This example assumes that you will download thechef_handler
repository as a .zip file, but you can also clone the repository if you prefer. -
Extract the
windows
andchef_handler
cookbooks to directories in your cookbooks directory namedwindows
andchef_handler
, respectively. -
Create a directory in your cookbooks directory named
install-iis
and navigate to it. -
Add a
metadata.rb
file toinstall-iis
with the following content.name "install-iis" version "0.1.0" depends "windows"
The
depends
directive allows you to use thewindows
cookbook resources in your recipes. -
Add a
recipes
directory toinstall-iis
and add a file nameddefault.rb
to that directory that contains the following recipe code.%w{ IIS-WebServerRole IIS-WebServer }.each do |feature| windows_feature feature do action :install end end service 'w3svc' do action [:start, :enable] end
The recipe uses the
windows
cookbook'swindows_feature
resource to install the following:-
The IIS Web Server role
. -
The IIS Web Server
.
The recipe then uses a
service
resource to start and enable the IIS service (W3SVC). Note
For a complete list of available Windows features, use RDP to log in to the instance, open a command prompt window, and run the following command. Note that the list is quite long.
dism /online /Get-Features
-
-
Create a
.zip
archive that contains theinstall-iis
,chef_handler
, andwindows
cookbooks and upload the archive to an S3 bucket. Make the archive public and record the URL for later use. This example assumes that the archive is namedinstall-iis.zip
. For more information, see Cookbook Repositories.Content delivered to Amazon S3 buckets might contain customer content. For more information about removing sensitive data, see How Do I Empty an S3 Bucket? or How Do I Delete an S3 Bucket?.
Create a stack for this example as follows. You also can use an existing Windows stack. Just update the cookbooks, as described later.
Create a stack
-
Open the AWS OpsWorks Stacks console
and choose Add Stack. Specify the following settings, accept the defaults for the other settings, and choose Add Stack. -
Name – InstallIIS
-
Region – US West (Oregon)
This example will work in any region, but we recommend using US West (Oregon) for tutorials.
-
Default operating system – Microsoft Windows Server 2012 R2
-
-
Choose Add a layer and add a custom layer to the stack with the following settings.
-
Name – IIS
-
Short name – iis
-
-
Add a 24/7 instance with default settings to the IIS layer and start it.
You can now install the cookbook and run the recipe
To install the cookbook and run the recipe
-
Edit the stack to enable custom cookbooks, and specify the following settings.
-
Repository type – S3 Archive
-
Repository URL – The cookbook archive's URL that you recorded earlier.
Accept the default values for the other settings and choose Save to update the stack configuration.
-
-
Run the Update Custom Cookbooks stack command, which installs the latest version of your custom cookbooks on the stack's online instances. If an earlier version of your cookbooks is present, this command overwrites it.
-
Execute the recipe by running the Execute Recipes stack command with Recipes to execute set to
install-iis::default
. This command initiates a Chef run, which runs the specified recipes.Note
This example uses Execute Recipes for convenience, but you typically have AWS OpsWorks Stacks run your recipes automatically by assigning them to the appropriate lifecycle event. You can run such recipes by manually triggering the event. You can use a stack command to trigger Setup and Configure events, and a deploy command to trigger Deploy and Undeploy events.
-
To verify the installation, use RDP to connect to the instance and open Windows Explorer. The file system should now have a
C:\inetpub
directory. If you check the list of services in the Administrative Tools Control Panel application, IIS should be near the bottom. However, it will be named World Wide Web Publishing Service, not IIS.