AWS accounts
Give learners access to AWS accounts.
This guide explains how to access an Amazon Web Services (AWS) account from Instruqt.
An AWS account is a container for your AWS resources. You create and manage your AWS resources in an AWS account, and the AWS account provides administrative capabilities for access and billing.
Before you begin
You must have already built a track to which you can add access to an AWS account.
Service Limits AWS accounts have built in service limits. If you plan to deploy complex network infrastructure check to make sure you do not exceed the EC2 service quota defaults.
Access AWS accounts
It is best to add the Instruqt Cloud Client container to your track to give a learner access to an AWS account. Because the Instruqt Cloud Client container:
Exposes links to the AWS Console for the resources configured in the
config.yml
file, with the credentials required to log in.Includes the
aws
CLI, pre-configured with the required credentials.
The AWS Console and the aws
CLI make it easy for content developers and learners to access AWS resources from the sandbox.
It takes the following steps to give learners access to an AWS account:
Add an Instruqt Cloud Client container to your track.
Add an AWS account to your track.
Add tabs to your challenges where you want to expose the AWS console or
aws
CLI.
Additionally, you can use:
A set of environment variables that are available in the
aws
CLI.IAM policies and permissions.
Use the AWS Cloud Account
template
Instead of building the track yourself, you can create a track with the AWS Cloud Template. The template includes:
The Instruqt Cloud Client container
A pre-defined AWS account
A challenge with tabs for AWS console and
aws
CLI
Step 1: Add an Instruqt Cloud Client container to your track
Click the track where you want to add an AWS account to. ↳ Instruqt shows the corresponding Track dashboard page.
In the Sandbox section, click Edit to open the Sandbox page.
Click + Add a host.
Pick the Container host type.
Input these values:
Click Show optional settings. Enter these values:
Click Save host to add the container.
Step 2: Add an AWS account to your track
Click + Add a cloud account on the Sandbox page. ↳ The Add cloud account pop-up opens.
Select the Amazon provider.
In the Name field, enter
awsaccount
.In the Services field, select the services that are going to be enabled.
In the Regions field, select the regions that are going to be enabled.
In the User IAM Policy field, enter an IAM policy in JSON format. For example to allow EC2 access:
In the Admin IAM Policy field, enter an IAM policy in JSON format. For example to allow EC2 access:
In the SCP Policy field, enter an SCP policy in JSON format. This example limits the allowed instance types:
Click Save to add the AWS account. ↳ On the Sandbox page, you will see the new AWS account.
Click Back to track to return to the Track dashboard page.
Only enabled services and regions configured by the team administrator can be selected and/or specified. See more details in Cloud services and regions
When specifying Admin Roles, an additional admin user and API Key will be created with the designated roles.
For setting up the cloud account in lifecycle scripts, it is recommended to use an admin user with elevated privileges. This ensures the ability to perform operations requiring higher privileges than those assigned to the end user.
Note: Admin credentials are injected exclusively into lifecycle scripts, unlike end user credentials which are exposed as environment variables on virtual machines and containers.
Step 3: Add tabs to expose the AWS console and aws
CLI
aws
CLIIn the Challenges section of the Track dashboard, click Add new, and select Assignment.
Input these values:
Click Save.
Click Tabs followed by Add new tab.
Select the Your applications tab type.
Enter/select these values to set the AWS console:
Click Save to add the tab.
Click Add new tab again.
Select the Terminal tab type.
Enter/select these values to set the
aws
CLI:Click Save to add the tab.
Click Back to track.
Click Play track and test your AWS account track.
Environment variables
Adding an AWS account to your track also sets a list of environment variables that you can use in commands and scripts:
Example
This example shows the id of the AWS account from a terminal by using two environment variables. The value of the INSTRUQT_AWS_ACCOUNTS
environment variable is inserted in the INSTRUQT_AWS_ACCOUNT_${NAME}_ACCOUNT_ID
environment variable.
To follow along:
Start your AWS account track and start the first challenge.
Move over to the
Cloud CLI
terminal and enter the following command:↳ The terminal shows the id of your AWS account project.
Setting policies and permissions
AWS accounts have the following settings to configure policies and permissions:
Managed policies
Identity And Access (IAM) policies
Service control policies (SCP) policies
Setting managed policies
An AWS managed policy is a standalone policy that is created and administered by AWS.
The managed policies method is easier than the IAM and SCP policies but may grant learners more than the minimum access required to complete a track. The following example grants Virtual Private Cloud (VPC) administrator access, which allows learners to create and manage VPC networks:
Update your AWS account by entering the following in the User Managed Policies field:
And clicking Add.
See AWS managed policies on the AWS docs site for more information.
Setting IAM policies
IAM policies define permissions for an action regardless of the method that you use to perform the operation.
For more fine-grained control, you can set IAM policies. The following example sets a managed policy that limits the EC2 instance types to only several t2 and t3 instances. Note the use of the pipe symbol |
to indicate that a multi-line JSON policy will follow.
Update your AWS account by entering the following pin the IAM policy field:
See IAM on the AWS docs site for more information.
Setting SCP policies
Service control policies (SCPs) are a type of organization policy that you can use to manage permissions in your organization.
For more fine-grained control, you can also set SCP policies. The following example disallows EC2 instance types except t2.large.
Update your AWS account by entering the following in the SCP policy field:
See Service control policies on the AWS docs site for more information.
Example SCP policies:
Limiting the instance types that can be used in EC2
To limit the allowed instance types, both the ec2.RunInstances
as the ec2.ModifyInstanceAttributes
actions need to be specified. The example below limits instance types to t2.micro
only.
Awesome! Your learners can now access AWS accounts. But there is more. You can also give them access to:
Last updated