Restricted IAM Policy on ARN
Restricted IAM Policies on Resource ARN¶
With this policy example, the customer is expected to apply restrictions on Resource ARN
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "IAMRequesttags",
"Effect": "Allow",
"Action": [
"iam:TagRole"
],
"Resource": "arn:aws:iam::<account-id>:role/*",
"Condition": {
"Null": {
"aws:RequestTag/env": "false",
"aws:RequestTag/email": "false"
}
}
},
{
"Sid": "IAMOIDC",
"Effect": "Allow",
"Action": [
"iam:GetOpenIDConnectProvider",
"iam:CreateOpenIDConnectProvider",
"iam:TagOpenIDConnectProvider",
"iam:ListOpenIDConnectProviderTags",
"iam:DeleteOpenIDConnectProvider"
],
"Resource": "arn:aws:iam::<account-id>:oidc-provider/*",
"Condition": {
"Null": {
"aws:RequestTag/env": "false",
"aws:RequestTag/email": "false"
}
}
},
{
"Effect": "Allow",
"Action": [
"iam:PassRole"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"iam:PassedToService": [
"eks.amazonaws.com",
"ec2.amazonaws.com"
]
},
"ArnLike": {
"iam:AssociatedResourceArn": "arn:aws:iam::<account-id>:role/rafay-*"
}
}
},
{
"Effect": "Allow",
"Action": [
"iam:GetInstanceProfile",
"iam:GetRole",
"iam:ListInstanceProfiles",
"iam:ListInstanceProfilesForRole",
"iam:GetRolePolicy",
"iam:ListRoleTags",
"iam:ListAttachedRolePolicies",
"iam:ListPolicyVersions",
"iam:GetPolicy",
"iam:GetPolicyVersion"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"cloudformation:ListStacks",
"cloudformation:ListStackResources",
"cloudformation:ListStackSets",
"cloudformation:ListChangeSets",
"cloudformation:DescribeStacks",
"cloudformation:DescribeStackResources",
"cloudformation:DescribeStackResource",
"cloudformation:DescribeStackEvents",
"cloudformation:DescribeChangeSet",
"cloudformation:DescribeStackSet",
"cloudformation:GetTemplate"
],
"Resource": "arn:aws:cloudformation:<region>:<account-id>:stack/*"
},
{
"Effect": "Allow",
"Action": [
"cloudformation:CreateStackSet",
"cloudformation:CreateStack",
"cloudformation:CreateChangeSet"
],
"Resource": "arn:aws:cloudformation:<region>:<account-id>:stack/*",
"Condition": {
"StringEquals": {
"aws:RequestTag/<KEY>": "<VALUE>"
}
}
},
{
"Effect": "Allow",
"Action": [
"cloudformation:DeleteStackSet",
"cloudformation:UpdateStackSet",
"cloudformation:UpdateStack",
"cloudformation:DeleteStack",
"cloudformation:DeleteChangeSet",
"cloudformation:ExecuteChangeSet"
],
"Resource": "arn:aws:cloudformation:<region>:<account-id>:stack/*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/<KEY>": "<VALUE>"
}
}
},
{
"Effect": "Allow",
"Action": [
"eks:AccessKubernetesApi",
"eks:CreatePodIdentityAssociation",
"eks:DescribePodIdentityAssociation",
"eks:DeletePodIdentityAssociation",
"eks:UpdatePodIdentityAssociation",
"eks:ListPodIdentityAssociations",
"eks:DescribeNodegroup",
"eks:DescribeCluster",
"eks:DescribeAddon",
"eks:DescribeAddonVersions",
"eks:DescribeFargateProfile",
"eks:DescribeUpdate",
"eks:ListTagsForResource",
"eks:ListUpdates",
"eks:ListClusters",
"eks:ListNodegroups",
"eks:ListAddons",
"eks:ListFargateProfiles"
],
"Resource": "arn:aws:eks:<region>:<account-id>:cluster/*"
},
{
"Effect": "Allow",
"Action": [
"eks:CreateCluster",
"eks:CreateNodegroup",
"eks:CreateFargateProfile"
],
"Resource": "arn:aws:eks:<region>:<account-id>:cluster/*",
"Condition": {
"StringEquals": {
"aws:RequestTag/<KEY>": "<VALUE>"
}
}
},
{
"Effect": "Allow",
"Action": [
"eks:TagResource"
],
"Resource": "arn:aws:eks:<region>:<account-id>:cluster/*",
"Condition": {
"StringEquals": {
"aws:RequestTag/<KEY>": "<VALUE>"
}
}
},
{
"Effect": "Allow",
"Action": [
"eks:UpdateClusterVersion",
"eks:UpdateClusterConfig",
"eks:DeleteCluster",
"eks:UpdateAddon",
"eks:UpdateNodegroupConfig",
"eks:UpdateNodegroupVersion",
"eks:CreateAddon",
"eks:DeleteAddon",
"eks:DeleteNodegroup",
"eks:DeleteFargateProfile",
"eks:UntagResource"
],
"Resource": "arn:aws:eks:<region>:<account-id>:cluster/*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/<KEY>": "<VALUE>"
}
}
},
{
"Effect": "Allow",
"Action": [
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribeLaunchConfigurations",
"autoscaling:DescribeScheduledActions",
"autoscaling:DescribeScalingActivities"
],
"Resource": "arn:aws:autoscaling:<region>:<account-id>:autoScalingGroup*"
},
{
"Effect": "Allow",
"Action": [
"autoscaling:CreateOrUpdateTags",
"autoscaling:CreateLaunchConfiguration",
"autoscaling:CreateAutoScalingGroup"
],
"Resource": "arn:aws:autoscaling:<region>:<account-id>:autoScalingGroup*",
"Condition": {
"StringEquals": {
"aws:RequestTag/<KEY>": "<VALUE>"
}
}
},
{
"Effect": "Allow",
"Action": [
"autoscaling:TerminateInstanceInAutoScalingGroup",
"autoscaling:SetDesiredCapacity",
"autoscaling:UpdateAutoScalingGroup",
"autoscaling:DeleteAutoScalingGroup",
"autoscaling:SuspendProcesses",
"autoscaling:DeleteTags",
"autoscaling:DeleteLaunchConfiguration"
],
"Resource": "arn:aws:autoscaling:<region>:<account-id>:autoScalingGroup*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/<KEY>": "<VALUE>"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DescribeVpcAttribute",
"ec2:DescribeInternetGateways",
"ec2:DescribeTags",
"ec2:DescribeRouteTables",
"ec2:DescribeSecurityGroups",
"ec2:DescribeSecurityGroupRules",
"ec2:DescribeVolumes",
"ec2:DescribeSubnets",
"ec2:DescribeAvailabilityZones",
"ec2:DescribeImages",
"ec2:describeAddresses",
"ec2:DescribeVpcs",
"ec2:DescribeLaunchTemplates",
"ec2:DescribeLaunchTemplateVersions",
"ec2:DescribeImageAttribute",
"ec2:DescribeKeyPairs",
"ec2:DescribeInstances",
"ec2:DescribeInstanceTypeOfferings",
"ec2:DescribeNatGateways"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"ec2:RunInstances"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateLaunchTemplate",
"ec2:CreateLaunchTemplateVersion",
"ec2:DeleteLaunchTemplate",
"ec2:ImportKeyPair"
],
"Resource": "*",
"Condition": {
"ForAllValues:StringEquals": {
"aws:TagKeys": "<KEY>"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DeleteTags",
"ec2:AssociateRouteTable",
"ec2:ReleaseAddress",
"ec2:AllocateAddress"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/<KEY>": "<VALUE>"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateTags"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:RequestTag/<KEY>": "<VALUE>"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:CreateSecurityGroup"
],
"Resource": "*",
"Condition": {
"ForAllValues:StringEquals": {
"aws:TagKeys": "<KEY>"
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:DeleteSecurityGroup",
"ec2:RevokeSecurityGroupEgress",
"ec2:AuthorizeSecurityGroupEgress",
"ec2:RevokeSecurityGroupIngress",
"ec2:AuthorizeSecurityGroupIngress"
],
"Resource": "*",
"Condition": {
"ForAllValues:StringEquals": {
"aws:TagKeys": ["<KEY>","aws:eks:cluster-name"]
}
}
},
{
"Effect": "Allow",
"Action": [
"ec2:ModifySecurityGroupRules",
"ec2:UpdateSecurityGroupRuleDescriptionsIngress",
"ec2:UpdateSecurityGroupRuleDescriptionsEgress"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/<KEY>": "<VALUE>"
}
}
},
{
"Effect": "Allow",
"Action": "ssm:GetParameter",
"Resource": "arn:aws:ssm:*:*:parameter/aws/service/*"
},
{
"Effect": "Allow",
"Action": [
"kms:DescribeKey"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"kms:CreateGrant"
],
"Resource": "*"
}
]
}
Note
For customers who will manage their own IAM Roles and Policies, (3) ARNs are required when provisioning managed K8s clusters.
- Service Role ARN
- Instance Profile ARN
- Instance Role ARN