AWS customers with healthcare compliance requirements such as the U.S. Health Insurance Portability and Accountability Act (HIPAA) and Good Laboratory, Clinical, and Manufacturing Practices (GxP) might want to control access to the AWS services their developers use to build and operate their GxP and HIPAA systems. For example, customers with GxP requirements might approve AWS as a supplier on the basis of AWS’s SOC certification and therefore want to ensure that only the services in scope for SOC are available to developers of GxP systems. Likewise, customers with HIPAA requirements might want to ensure that only AWS HIPAA Eligible Services are available to store and process protected health information (PHI). Now with AWS Organizations—policy-based management for multiple AWS accounts—you can programmatically control access to the services within your AWS accounts.
In this blog post, I show how to restrict an AWS account to HIPAA Eligible Services as well as explain why you should include additional supporting AWS services with service control policies (SCPs) in AWS Organizations. Although this example is HIPAA related, you can repurpose it for GxP, a database of Genotypes and Phenotypes (dbGaP) solutions, or other healthcare compliance requirements for which you want to control developers’ access to a specific scope of services.
Managing an account hierarchy with AWS Organizations
Let’s say I manage four AWS accounts: a Payer account, a Development account, a Corporate IT account, and a fourth account that contains PHI. In accordance with AWS’s Business Associate Agreement (BAA), I want to be sure that only AWS HIPAA Eligible Services are allowed in the fourth account along with supporting AWS services that help encrypt and control access to the account. The following diagram shows a logical view of the associated account structure.
As illustrated in the preceding diagram, Organizations allows me to create this account hierarchy between the four AWS accounts I manage. Before I proceed to show how to create and apply an SCP to the HIPAA account in this hierarchy, I’ll define some Organizations terminology that I use in this post:
- Organization – A consolidated set of AWS accounts that you manage. For the preceding example, I have already created my organization and invited my accounts. For more information about creating an organization and inviting accounts, see AWS Organizations – Policy-Based Management for Multiple AWS Accounts.
- Master account – The management hub for Organizations. This is where I invite existing accounts, create new accounts and manage my SCPs. I run all commands demonstrated in this post from this master account. This is also my payer account in the preceding account structure diagram.
- Service control policy (SCP) – A set of controls that the organization’s master account can apply to the organization, selected OUs, and selected accounts. SCPs allow me to whitelist or blacklist services and actions that I can delegate to the users and roles in the account to which the SCPs are applied. The resultant security permissions for a user and role are the union of the permissions in an SCP and the permissions in an AWS Identity and Access Management (IAM) policy. I refer to SCPs as a policy type in some of this post’s command-line arguments.
- Note: SCPs are available only if your organization is in All Features mode. For more information, see Enabling All Features in Your Organization.
- Organizational unit (OU) – A container for a set of AWS accounts. OUs can be arranged into a hierarchy that can be as many as five levels deep. The top of the hierarchy of OUs is also known as the administrative root. In the walkthrough, I create a HIPAA OU and apply my policy to that OU. I then move the account into the OU to have the policy applied. To manage the organization depicted above, I might create OUs for my Corporate IT account and my Development account.
To restrict services in the fourth account to HIPAA Eligible Services and required supporting services, I will show how to create and apply an SCP to the account with the following steps:
- Create a JSON document that lists HIPAA Eligible Services and supporting AWS services.
- Create an SCP with a JSON document.
- Create an OU for the HIPAA account, and move the account into the OU.
- Attach the SCP to the HIPAA OU.
- Verify which SCPs are attached to the HIPAA OU.
- Detach the default FullAWSAccess SCP from the OU.
- Verify SCP enforcement.
How to create and apply an SCP to an account
Let’s walk through the steps to create an SCP and apply it to an account. I can manage my organization by using the Organizations console, AWS CLI, or AWS API from my master account. For the purposes of this post, I will demonstrate the creation and application of an SCP to my account by using the AWS CLI.
1. Create a JSON document that lists HIPAA Eligible Services and supporting AWS services
Creating an SCP will be familiar if you have experience writing an IAM policy because the grammar in crafting the policy is similar. I will create a JSON document that lists only the services I want to allow in my account, and I will use this JSON document to create my SCP via the command line. The SCP I create from this document allows all actions for all resources of the listed services, effectively turning on only these services in my account. I name the document HIPAAExample.json and save it to the directory from which I will demonstrate the CLI commands.
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"dynamodb:*","rds:*","ec2:*","s3:*","elasticmapreduce:*",
"glacier:*","elasticloadbalancing:*", "cloudwatch:*",
"importexport:*", "cloudformation:*", "redshift:*",
"iam:*", "health:*", "config:*", "snowball:*",
"trustedadvisor:*", "kms:*", "apigateway:*",
"autoscaling:*", "directconnect:*",
"execute-api:*", "sts:*"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
Note that the SCP includes more than just the HIPAA Eligible Services.
Why include additional supporting services in a HIPAA SCP?
You can use any service in your account, but you can use only HIPAA Eligible Services to store and process PHI. Some services, such as IAM and AWS Key Management Service (KMS), can be used because these services do not directly store or process PHI, but they might still be needed for administrative and security purposes.
To those ends, I include the following supporting services in the SCP to help me with account administration and security:
- Access controls – I include IAM to ensure that I can manage access to resources in the account. Though Organizations can limit whether a service is available, I still need the granularity of access control that IAM provides.
- Encryption – I need a way to encrypt the data. The integration of AWS KMS with Amazon Redshift, Amazon RDS, and Amazon Elastic Block Store (Amazon EBS) helps with this security requirement.
- Auditing – I also need to be able to demonstrate controls in practice, track changes, and discover any malicious activity in my account. You will note that AWS CloudTrail is not included in the SCP, which prohibits any mutating actions against CloudTrail from users within the account. However, when setting up the account, CloudTrail was set up to send logs to a logging account as recommended in AWS Multiple Account Security Strategy. The logs do not reside in the account, and no one has privileges to change the trail including root or administrators, which helps ensure the protection of the API logging of the account. This highlights how SCPs can be used to secure services in an account.
- Automation – Automation can help me with my security controls as shown in How to Translate HIPAA Controls to AWS CloudFormation Templates: Part 3 of the Automating HIPAA Compliance Series; therefore, I consider including AWS CloudFormation as a way to ensure that applications deployed in the account adhere to my security and compliance policies. Auto Scaling also is an important service to include to help me scale to meet demand and control cost.
- Monitoring and support – The remaining services in the SCP such as Amazon CloudWatch are needed to make sure that I can monitor the environment and have visibility into the health of the workloads and applications in my AWS account, helping me maintain operational control. AWS Trusted Advisor is a service that helps to make sure that my cloud environment is well architected.
Now that I have created my JSON document with the services that I will include and explained in detail why I include them, I can create my SCP.
2. Create an SCP with a JSON document
I will now create the SCP via the CLI with the aws organizations create-policy command. Using the name parameter, I name the SCP and define that I am creating an SCP, both of which are required parameters. I then provide a brief description of the SCP and specify the location of the JSON document I created in Step 1.
aws organizations create-policy --name hipaa-example-policy --type SERVICE_CONTROL_POLICY --description
"All HIPAA eligible services plus supporting AWS Services." --content file://./HIPAAExample.json
Output
{
"policy": {
"policySummary": {
"type": "SERVICE_CONTROL_POLICY",
"arn": "arn:aws:organizations::012345678900:policy/o-kzceys2q4j/SERVICE_CONTROL_POLICY/p-6ldl8bll",
"name": "hipaa-example-policy",
"awsManaged": false,
"id": "p-6ldl8bll", "description": "All HIPAA eligible services and supporting AWS services."
I take note of the policy-id because I need it to attach the SCP to my OU in Step 4. Note: Throughout this post, fictitious placeholder values are shown for the purposes of demonstrating this post’s solution.
3. Create an OU for the HIPAA account, and move the account into the OU
Grouping accounts by function will make it easier to manage the organization and apply policies across multiple accounts. In this step, I create an OU for the HIPAA account and move the target account into the OU. To create an OU, I need to know the ID for the parent object under which I will be placing the OU. In this case, I will place it under the root and need the ID for the root. To get the root ID, I run the list-roots command.
aws organizations list-roots
Output
{
"Roots": [
{
"PolicyTypes": [
{
"Status": "ENABLED",
"Type": "SERVICE_CONTROL_POLICY"
}
],
"Id": "r-rth4",
"Arn": "arn:aws:organizations::012345678900:root/o-p9bx61i0h1/r-rth4",
"Name": "Root"
}
]
}
With the root ID, I can proceed to create the OU under the root.
aws organizations create-organizational-unit --parent-id r-rth4 --name HIPAA-Accounts
Output
{
"OrganizationalUnit": {
"Id": "ou-rth4-ezo5wonz",
"Arn": "arn:aws:organizations::012345678900:ou/o-p9bx61i0h1/ou-rth4-ezo5wonz",
"Name": "HIPAA-Accounts"
}
}
I take note of the OU ID in the output because I need it in the next command to move my target account. I will also need the root ID in the command because I am moving the target account from the root into the OU.
aws organizations move-account --account-id 098765432110 --source-parent-id r-rth4 --destination-parent-id
ou-rth4-ezo5wonz
No Output
4. Attach the SCP to the HIPAA OU
Even though you may have enabled All Features in your organization, you still need to enable SCPs at the root level of the organization to attach SCPs to objects. To do this in my case, I will run the enable-policy-type command and provide the root ID.
aws organizations enable-policy-type --root-id r-rth4 --policy-type SERVICE_CONTROL_POLICY
Output
{
"Root": {
"PolicyTypes": [],
"Id": "r-rth4",
"Arn": "arn:aws:organizations::012345678900:root/o-p9bx61i0h1/r-rth4",
"Name": "Root"
}
}
Now, I will attach the SCP to the OU by using the aws organizations attach-policy command. I must include the target-id, which is the OU ID noted in the previous step and the policy-id from the output of the command in Step 2.
aws organizations attach-policy --target-id ou-rth4-ezo5wonz --policy-id p-6ldl8bll
No Output
5. Verify which SCPs are attached to the HIPAA OU
I will now verify which SCPs are attached to my account by using the aws organization list-policies-for-target command. I must provide the OU ID with the target-id parameter and then filter for SERVICE_CONTROL_POLICY type.
aws organizations list-policies-for-target --target-id ou-rth4-ezo5wonz --filter SERVICE_CONTROL_POLICY
Output
{
"policies": [
{
"awsManaged": false,
"arn": "arn:aws:organizations::012345678900:policy/o-kzceys2q4j/SERVICE_CONTROL_POLICY/p-6ldl8bll",
"id": "p-6ldl8bll",
"description": "All HIPAA eligible services plus supporting AWS Services.",
"name": "hipaa-example-policy",
"type": "SERVICE_CONTROL_POLICY"
},
{
"awsManaged": true,
"arn": "arn:aws:organizations::aws:policy/SERVICE_CONTROL_POLICY/p-FullAWSAccess",
"id": "p-FullAWSAccess",
"description": "Allows access to every operation",
"name": "FullAWSAccess",
"type": "SERVICE_CONTROL_POLICY"
}
]
}
As the output shows, two SCPs are attached to this account. I want to detach the FullAWSAccess SCP so that the HIPAA SCP is properly in effect. The FullAWSAccess SCP is an Allow SCP that allows all AWS services. If I were to leave the default FullAWSAccess SCP in place, it would grant access to services I do not want to allow in my account. Detaching the FullAWSAccess SCP means that only the services I allow in the hipaa-example-policy are allowed in my account. Note that if I were to create a Deny SCP, the SCP would take precedence over an Allow SCP.
6. Detach the default FullAWSAccess SCP from the OU
Before detaching the default FullAWSAccess SCP from my account, I run the aws workspaces describe-workspaces call from the Amazon WorkSpaces API. I am currently not running any WorkSpaces, so the output shows an empty list. However, I will test this again after I detach the FullAWSAccess SCP from my account and am left with only the HIPAA SCP attached to the account.
aws workspaces describe-workspaces
Output
{
"Workspaces": []
}
In order to detach the FullAWSAccess SCP, I must run the aws organizations detach-policy command, providing it the policy-id and target-id of the OU.
aws organizations detach-policy --policy-id p-FullAWSAccess --target-id ou-rth4-ezo5wonz
No Output
If I rerun the list-policies-for-target command again, I see that only one SCP is attached to my account that allows HIPAA Eligible Services, as shown in the following output.
aws organizations list-policies-for-target --target-id ou-rth4-ezo5wonz --filter SERVICE_CONTROL_POLICY
Output
{
"policies": [
{
"name": "hipaa-example-policy",
"arn": "arn:aws:organizations::012345678900:policy/o-kzceys2q4j/SERVICE_CONTROL_POLICY/p-6ldl8bll",
"description": "All HIPAA eligible services plus supporting AWS Services.",
"awsManaged": false,
"id": "p-6ldl8bll",
"type": "SERVICE_CONTROL_POLICY"
}
]
}
Now I can test and verify the enforcement of this SCP.
7. Verify SCP enforcement
Previously, the administrator of the account had full access to all AWS services, including Amazon WorkSpaces. His IAM policy for Amazon WorkSpaces allows all actions for Amazon WorkSpaces. However, after I apply the HIPAA SCP to the account, this changes the effect of the IAM policy to deny all actions for Amazon WorkSpaces because it is not an allowed service.
The following screenshot of the IAM policy simulator shows which permissions are set for the administrator after I apply the HIPAA SCP. Also, note that the IAM policy simulator shows that the Deny permission is being denied by Organizations. Because the policy simulator is aware of the SCPs attached to an account, it is a good tool to use when troubleshooting or validating an SCP.
If I run the aws workspaces describe-workspaces call again as I did in Step 5, this time I receive an AccessDeniedException error, which validates that the HIPAA SCP is working because Amazon WorkSpaces is not an allowed service in the SCP.
aws workspaces describe-workspaces
Output
An error occurred (AccessDeniedException) when calling the DescribeWorkspaces operation:
User: arn:aws:iam::098765432110:user/admin is not authorized to perform: workspaces:DescribeWorkspaces
on resource: arn:aws:workspaces:us-east-1:098765432110:workspace/*
This completes the process of creating and applying an SCP to my account.
Summary
In this blog post, I have shown how to create an SCP and attach it to an OU to restrict an account to HIPAA Eligible Services and additional supporting services. I also showed how to create an OU, move an account into the OU, and then validate the SCP attached to the OU. For more information, see AWS Cloud Computing in Healthcare.
If you have comments about this post, submit them in the “Comments” section below. If you have questions about or issues with implementing this solution, please start a new thread on the IAM forum.