Skip to content

Commit 0d34f33

Browse files
committed
Adding service-specific guidance for sns, logs, s3
1 parent 712812a commit 0d34f33

33 files changed

Lines changed: 956 additions & 178 deletions

README.md

Lines changed: 36 additions & 31 deletions
Large diffs are not rendered by default.

resource_control_policies/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ RCPs are a type of [AWS Organizations](https://aws.amazon.com/organizations/) or
1818

1919
This folder contains examples of RCPs that help enforce identity and network perimeter controls on [services supported by RCPs](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps.html#rcp-supported-services). This folder also includes policy examples you can implement as [resource-based policies](resource_based_policies) for select services that are not supported by RCPs.
2020

21-
These examples do not represent a complete list of valid data access patterns, and they are intended for you to tailor and extend them to suit the needs of your environment. See [Tagging conventions](https://github.com/aws-samples/data-perimeter-policy-examples/tree/main?tab=readme-ov-file#tagging-conventions) used in the policy examples to control the scope of data perimeter guardrails. You can also use the `NotResource` IAM policy element to exclude specific resources from the controls.
21+
These examples do not represent a complete list of valid data access patterns, and they are intended for you to tailor and extend them to suit the needs of your environment. See [Tagging conventions](https://github.com/aws-samples/data-perimeter-policy-examples/tree/main?tab=readme-ov-file#tagging-conventions-and-governance) used in the policy examples to control the scope of data perimeter guardrails. You can also use the `NotResource` IAM policy element to exclude specific resources from the controls.
2222

2323
Use the following RCP examples individually or in combination:
2424
* [identity_perimeter_rcp](identity_perimeter_rcp.json) – Enforces identity perimeter controls on resources within your Organizations organization.

service_control_policies/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ This statement is included in the [data_perimeter_governance_scp](data_perimeter
129129

130130
[Some AWS resources](https://docs.aws.amazon.com/ram/latest/userguide/shareable.html#shareable-r53.) allow cross-account sharing via AWS RAM instead of resource-based policies. By default, AWS RAM shares allow sharing outside of an Organizations organization. You can explicitly [restrict sharing of resources outside of AWS Organizations](https://docs.aws.amazon.com/ram/latest/userguide/working-with-sharing-create.html) and then limit AWS RAM actions based on this configuration.
131131

132-
### "Sid":"PreventExternalResourceShare"
132+
### "Sid":"PreventExternalResourceShare" and "Sid": "PreventExternalResourceShareKMS"
133133

134-
This statement is included in the [data_perimeter_governance_scp](data_perimeter_governance_scp.json) and restricts resource sharing by capabilities that are embedded into services.
134+
These statements are included in the [data_perimeter_governance_scp](data_perimeter_governance_scp.json) and restrict resource sharing by capabilities that are embedded into services.
135135

136136
Some AWS services use neither resource-based policies nor AWS RAM.
137137

@@ -166,6 +166,7 @@ Example data access patterns:
166166
* [AWS Cloud9 shared environment](https://docs.aws.amazon.com/cloud9/latest/user-guide/share-environment.html): You can share AWS Cloud9 development environment with users from other accounts with the `CreateEnvironmentMembership` API.
167167
* [Amazon Connect dataset](https://docs.aws.amazon.com/connect/latest/APIReference/API_BatchAssociateAnalyticsDataSet.html#connect-BatchAssociateAnalyticsDataSet-request-DataSetIds): You can associate a list of Amazon Connect instance analytics datasets to a target account using `BatchAssociateAnalyticsDataSet` API.
168168
* [Amazon Redshift Serverless snapshot](https://docs.aws.amazon.com/redshift-serverless/latest/APIReference/API_PutResourcePolicy.html): You can share snapshots across AWS accounts using `PutResourcePolicy` API.
169+
* [AWS KMS grants](https://docs.aws.amazon.com/kms/latest/developerguide/grants.html): The `CreateGrant` API allows you to add a grant for another account to use your KMS key.
169170

170171
### "Sid":"ProtectActionsNotSupportedByPrimaryDPControls"
171172

service_control_policies/data_perimeter_governance_scp.json

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,21 @@
6565
}
6666
}
6767
},
68+
{
69+
"Sid": "PreventExternalResourceShareKMS",
70+
"Effect": "Deny",
71+
"Action": "kms:CreateGrant",
72+
"Resource": "*",
73+
"Condition": {
74+
"BoolIfExists": {
75+
"kms:GrantIsForAWSResource": "false",
76+
"aws:PrincipalIsAWSService": "false"
77+
},
78+
"StringNotEqualsIfExists": {
79+
"aws:PrincipalTag/dp:exclude:identity": "true"
80+
}
81+
}
82+
},
6883
{
6984
"Sid": "ProtectActionsNotSupportedByPrimaryDPControls",
7085
"Effect": "Deny",
@@ -101,20 +116,20 @@
101116
}
102117
},
103118
{
104-
"Sid":"PreventLambdaFunctionURLAuthNone",
105-
"Effect":"Deny",
106-
"Action":[
119+
"Sid": "PreventLambdaFunctionURLAuthNone",
120+
"Effect": "Deny",
121+
"Action": [
107122
"lambda:AddPermission",
108123
"lambda:UpdateFunctionUrlConfig",
109124
"lambda:CreateFunctionUrlConfig"
110125
],
111-
"Resource":"*",
112-
"Condition":{
113-
"StringNotEqualsIfExists":{
126+
"Resource": "*",
127+
"Condition": {
128+
"StringNotEqualsIfExists": {
114129
"aws:PrincipalTag/dp:exclude:identity": "true"
115130
},
116131
"StringEquals": {
117-
"lambda:FunctionUrlAuthType" : "NONE"
132+
"lambda:FunctionUrlAuthType": "NONE"
118133
}
119134
}
120135
},
@@ -136,4 +151,4 @@
136151
}
137152
}
138153
]
139-
}
154+
}

service_control_policies/service_specific_controls/README.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ This folder contains examples of SCPs with service-specific controls you might w
88

99
Use the following example SCPs individually or in combination:
1010

11-
* [network_perimeter_ec2_scp](/service_control_policies/service_specific_controls/network_perimeter_ec2_scp.json) – Enforces network perimeter controls on service roles used by Amazon EC2 instances.
12-
* [network_perimeter_iam_users_scp](/service_control_policies/service_specific_controls/network_perimeter_iam_users_scp.json) - Enforces network perimeter controls on IAM users with long-term access keys.
13-
* [network_perimeter_lambda_scp](/service_control_policies/service_specific_controls/network_perimeter_lambda_scp.json) - Enforces network perimeter controls on service roles used by AWS Lambda.
14-
* [restrict_nonvpc_deployment_scp](/service_control_policies/service_specific_controls/restrict_nonvpc_deployment_scp.json) - Enforces deployment of resources in a customer managed Amazon VPC.
15-
* [restrict_idp_configurations_scp](/service_control_policies/service_specific_controls/restrict_idp_configurations_scp.json) - Restricts the ability to make configuration changes to the IAM SAML identity providers.
16-
* [restrict_untrusted_endpoints_scp](/service_control_policies/service_specific_controls/restrict_untrusted_endpoints_scp.json) - Prevent untrusted non-AWS resources from being configured as targets for service operations.
17-
* [restrict_presignedURL_scp](service_control_policies/service_specific_controls/restrict_presignedURL_scp.json) - Restricts the ability to create Amazon S3 presigned URLs within specific services.
11+
* [network_perimeter_ec2_scp](network_perimeter_ec2_scp.json) – Enforces network perimeter controls on service roles used by Amazon EC2 instances.
12+
* [network_perimeter_iam_users_scp](network_perimeter_iam_users_scp.json) - Enforces network perimeter controls on IAM users with long-term access keys.
13+
* [network_perimeter_lambda_scp](network_perimeter_lambda_scp.json) - Enforces network perimeter controls on service roles used by AWS Lambda.
14+
* [restrict_nonvpc_deployment_scp](restrict_nonvpc_deployment_scp.json) - Enforces deployment of resources in a customer managed Amazon VPC.
15+
* [restrict_idp_configurations_scp](restrict_idp_configurations_scp.json) - Restricts the ability to make configuration changes to the IAM SAML identity providers.
16+
* [restrict_untrusted_endpoints_scp](restrict_untrusted_endpoints_scp.json) - Prevent untrusted non-AWS resources from being configured as targets for service operations.
17+
* [restrict_presignedURL_scp](restrict_presignedURL_scp.json) - Restricts actions that create Amazon S3 presigned URLs that are presigned by a service principal.
18+
* [restrict_resource_policy_configurations_scp](restrict_resource_policy_configurations_scp.json) - Restricts the ability to configure resource-based policies.
1819

1920
Note that the SCP examples in this repository use a [deny list strategy](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps_strategies.html), which means that you also need a FullAWSAccess policy or other policy attached to your AWS Organizations organization entities to allow actions. You still also need to grant appropriate permissions to your principals by using identity-based or resource-based policies.
2021

@@ -75,28 +76,32 @@ This statement is included in the [restrict_nonvpc_deployment_scp](restrict_nonv
7576

7677
AWS services such as AWS CodeStar Connections do not support deployment within a VPC and provide direct access to the internet that is not controlled by your VPC. You can block the use of such services by using SCPs or implementing your own proxy solution to inspect egress traffic.
7778

78-
### "Sid":"PreventNonVPCDeploymentSageMaker", "Sid":"PreventNonVPCDeploymentGlueJob", "Sid":"PreventNonVPCDeploymentCloudShell", and "Sid":"PreventNonVPCDeploymentLambda", "Sid":"PreventNonVPCDeploymentAppRunner"
79+
### "Sid":"PreventNonVPCDeploymentSageMaker", "Sid":"PreventNonVPCDeploymentGlueJob", "Sid":"PreventNonVPCDeploymentCloudShell", "Sid":"PreventNonVPCDeploymentLambda", "Sid":"PreventNonVPCDeploymentAppRunner", and "Sid":"PreventNonVPCDeploymentCodeBuild"
7980

80-
These statements are included in the [restrict_nonvpc_deployment_scp](restrict_nonvpc_deployment_scp.json) and explicitly deny relevant [Amazon SageMaker](https://aws.amazon.com/sagemaker/), [AWS Glue](https://aws.amazon.com/glue/), [AWS CloudShell](https://aws.amazon.com/cloudshell/), [AWS Lambda](https://aws.amazon.com/lambda/), and [AWS AppRunner](https://aws.amazon.com/apprunner/) operations unless they have VPC configurations specified in the requests. Use these statements to enforce deployment in a VPC for these services.
81+
These statements are included in the [restrict_nonvpc_deployment_scp](restrict_nonvpc_deployment_scp.json) and explicitly deny relevant [Amazon SageMaker](https://aws.amazon.com/sagemaker/), [AWS Glue](https://aws.amazon.com/glue/), [AWS CloudShell](https://aws.amazon.com/cloudshell/), [AWS Lambda](https://aws.amazon.com/lambda/), [AWS AppRunner](https://aws.amazon.com/apprunner/), and [AWS CodeBuild](https://aws.amazon.com/codebuild/) operations unless they have VPC configurations specified in the requests. Use these statements to enforce deployment in a VPC for these services.
8182

8283
Services such as Lambda, AWS Glue, CloudShell, App Runner, and SageMaker support different deployment models. For example, [Amazon SageMaker Studio](https://aws.amazon.com/pm/sagemaker/) and [SageMaker notebook instances](https://docs.aws.amazon.com/sagemaker/latest/dg/nbi.html) allow direct internet access by default. However, they provide you with the capability to configure them to run within your VPC so that you can inspect requests by using VPC endpoint policies (against identity and resource perimeter controls) and enforce the network perimeter.
8384

8485

8586
### "Sid": "PreventNonVpcOnlySageMakerDomain"
8687

87-
This statement is included in the [restrict_nonvpc_deployment_scp](restrict_nonvpc_deployment_scp.json) and prevents users from creating [Amazon SageMaker domains](https://docs.aws.amazon.com/sagemaker/latest/dg/sm-domain.html) that can access the internet through a VPC managed by SageMaker, or updating SageMaker domains to allow access to the internet through a VPC managed by SageMaker.
88+
This statement is included in the [restrict_nonvpc_deployment_scp](restrict_nonvpc_deployment_scp.json) and prevents users from creating [Amazon SageMaker domains](https://docs.aws.amazon.com/sagemaker/latest/dg/sm-domain.html) that can access the Internet through a VPC managed by SageMaker, or updating SageMaker domains to allow access to the Internet through a VPC managed by SageMaker.
8889
For more details, see the definition of the parameter [`AppNetworkAccessType`](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_UpdateDomain.html#sagemaker-UpdateDomain-request-AppNetworkAccessType) in the Amazon SageMaker API Reference.
8990

9091

9192
### "Sid": "PreventDirectInternetAccessSageMakerNotebook"
9293

93-
This statement is included in the [restrict_nonvpc_deployment_scp](restrict_nonvpc_deployment_scp.json) and prevents users from creating [Amazon SageMaker Notebooks Instances](https://docs.aws.amazon.com/sagemaker/latest/dg/nbi.html) that can access the internet through a VPC managed by SageMaker.
94+
This statement is included in the [restrict_nonvpc_deployment_scp](restrict_nonvpc_deployment_scp.json) and prevents users from creating [Amazon SageMaker Notebooks Instances](https://docs.aws.amazon.com/sagemaker/latest/dg/nbi.html) that can access the Internet through a VPC managed by SageMaker.
9495
For more details, see [Connect a Notebook Instance in a VPC to External Resources](https://docs.aws.amazon.com/sagemaker/latest/dg/appendix-notebook-and-internet-access.html) in the Amazon SageMaker documentation.
9596

9697
### "Sid": "PreventUntrustedSNSEmailSubscriptions"
9798

98-
This statement is included in the [restrict_sns_subscription_scp](/service_control_policies/service_specific_controls/restrict_sns_subscription_scp.json) and prevents users from subscribing email addresses that belong to domains other than the one denoted by <trusted_email_domain> to an SNS topic. See [Amazon SNS policy keys](https://docs.aws.amazon.com/sns/latest/dg/sns-using-identity-based-policies.html#sns-policy-keys) for more details.
99+
This statement is included in the [restrict_untrusted_endpoints_scp](restrict_untrusted_endpoints_scp.json) and prevents users from subscribing email addresses that belong to domains other than the one denoted by `<trusted_email_domain>` to an SNS topic. See [Amazon SNS policy keys](https://docs.aws.amazon.com/sns/latest/dg/sns-using-identity-based-policies.html#sns-policy-keys) for more details.
99100

100101
### "Sid": "PreventCreationOfServicePresignedURL"
101102

102-
This statement is included in the [restrict_presignedURL_scp](service_control_policies/service_specific_controls/restrict_presignedURL_scp.json) and prevents users from creating Amazon S3 presigned URLs within specific services.
103+
This statement is included in the [restrict_presignedURL_scp](restrict_presignedURL_scp.json) and prevents users from creating Amazon S3 presigned URLs that are presigned by a service principal.
104+
105+
### "Sid": "PreventResourcePolicyConfigurations"
106+
107+
This statement is included in the [restrict_resource_policy_configurations_scp](restrict_resource_policy_configurations_scp.json) and prevents users from configuring resource-based policies for select services.

service_control_policies/service_specific_controls/restrict_nonvpc_deployment_scp.json

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
}
1616
},
1717
{
18-
"Sid":"PreventNonVPCDeploymentSageMaker",
19-
"Effect":"Deny",
20-
"Action":[
18+
"Sid": "PreventNonVPCDeploymentSageMaker",
19+
"Effect": "Deny",
20+
"Action": [
2121
"sagemaker:CreateAutoMLJob",
2222
"sagemaker:CreateAutoMLJobV2",
2323
"sagemaker:CreateCluster",
@@ -35,13 +35,13 @@
3535
"sagemaker:UpdateDomain",
3636
"sagemaker:UpdateMonitoringSchedule"
3737
],
38-
"Resource":"*",
39-
"Condition":{
38+
"Resource": "*",
39+
"Condition": {
4040
"StringNotEqualsIfExists": {
4141
"aws:PrincipalTag/dp:exclude": "true"
4242
},
43-
"Null":{
44-
"sagemaker:VpcSubnets":"true"
43+
"Null": {
44+
"sagemaker:VpcSubnets": "true"
4545
}
4646
}
4747
},
@@ -52,8 +52,8 @@
5252
"sagemaker:CreateDomain",
5353
"sagemaker:UpdateDomain"
5454
],
55-
"Resource": "*",
56-
"Condition": {
55+
"Resource": "*",
56+
"Condition": {
5757
"StringNotEqualsIfExists": {
5858
"aws:PrincipalTag/dp:exclude": "true",
5959
"sagemaker:AppNetworkAccessType": "VpcOnly"
@@ -66,8 +66,8 @@
6666
"Action": [
6767
"sagemaker:CreateNotebookInstance"
6868
],
69-
"Resource": "*",
70-
"Condition": {
69+
"Resource": "*",
70+
"Condition": {
7171
"StringEquals": {
7272
"sagemaker:DirectInternetAccess": "Enabled"
7373
},
@@ -77,24 +77,24 @@
7777
}
7878
},
7979
{
80-
"Sid":"PreventNonVPCDeploymentLambda",
81-
"Effect":"Deny",
82-
"Action":[
80+
"Sid": "PreventNonVPCDeploymentLambda",
81+
"Effect": "Deny",
82+
"Action": [
8383
"lambda:CreateFunction",
8484
"lambda:UpdateFunctionConfiguration"
8585
],
86-
"Resource":"*",
87-
"Condition":{
86+
"Resource": "*",
87+
"Condition": {
8888
"StringNotEqualsIfExists": {
8989
"aws:PrincipalTag/dp:exclude": "true"
9090
},
91-
"Null":{
92-
"lambda:VpcIds":"true"
91+
"Null": {
92+
"lambda:VpcIds": "true"
9393
}
9494
}
9595
},
9696
{
97-
"Sid":"PreventNonVPCDeploymentGlueJob",
97+
"Sid": "PreventNonVPCDeploymentGlueJob",
9898
"Effect": "Deny",
9999
"Action": [
100100
"glue:CreateJob",
@@ -117,7 +117,7 @@
117117
],
118118
"Effect": "Deny",
119119
"Resource": "*",
120-
"Condition": {
120+
"Condition": {
121121
"StringNotEqualsIfExists": {
122122
"aws:PrincipalTag/dp:exclude": "true"
123123
},
@@ -134,14 +134,33 @@
134134
"apprunner:UpdateService"
135135
],
136136
"Resource": "*",
137-
"Condition": {
137+
"Condition": {
138138
"StringNotEqualsIfExists": {
139139
"aws:PrincipalTag/dp:exclude": "true"
140140
},
141141
"Null": {
142142
"apprunner:VpcConnectorArn": "true"
143143
}
144144
}
145+
},
146+
{
147+
"Sid": "PreventNonVPCDeploymentCodeBuild",
148+
"Effect": "Deny",
149+
"Action": [
150+
"codebuild:CreateProject",
151+
"codebuild:UpdateProject",
152+
"codebuild:CreateFleet",
153+
"codebuild:UpdateFleet"
154+
],
155+
"Resource": "*",
156+
"Condition": {
157+
"StringNotEqualsIfExists": {
158+
"aws:PrincipalTag/dp:exclude": "true"
159+
},
160+
"Null": {
161+
"codebuild:vpcConfig": "true"
162+
}
163+
}
145164
}
146165
]
147-
}
166+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"Version": "2012-10-17",
3+
"Statement": [
4+
{
5+
"Sid": "PreventResourcePolicyConfigurations",
6+
"Effect": "Deny",
7+
"Action": [
8+
"codeartifact:PutRepositoryPermissionsPolicy",
9+
"codeartifact:PutDomainPermissionsPolicy",
10+
"codebuild:PutResourcePolicy",
11+
"dynamodb:PutResourcePolicy",
12+
"glacier:SetVaultAccessPolicy",
13+
"lambda:AddLayerVersionPermission",
14+
"lambda:AddPermission",
15+
"logs:PutResourcePolicy",
16+
"logs:PutDestinationPolicy",
17+
"sns:AddPermission"
18+
],
19+
"Resource": "*",
20+
"Condition": {
21+
"StringNotEqualsIfExists": {
22+
"aws:PrincipalTag/dp:exclude:identity": "true"
23+
}
24+
}
25+
}
26+
]
27+
}

0 commit comments

Comments
 (0)