Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
reports-read: Write an IAM identity policy that allows the caller to list the S3 bucket acme-reports and download objects from it, and that grants no other permissions.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::acme-reports",
"arn:aws:s3:::acme-reports/*"
]
}
]
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
reports-read: Write an IAM identity policy that allows the caller to list the S3 bucket acme-reports and download objects from it, and that grants no other permissions.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::acme-reports"
},
{
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::acme-reports/*"
}
]
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
reports-read: Write an IAM identity policy that allows the caller to list the S3 bucket acme-reports and download objects from it, and that grants no other permissions.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowS3ListGetObject",
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::acme-reports",
"arn:aws:s3:::acme-reports/*"
]
}
]
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
arns: Return a JSON object with these keys, each holding the corresponding ARN. function: Lambda function resize in us-east-1, account 123456789012. role: IAM role deployer in account 123456789012. object: the object logs/app.txt in S3 bucket acme-logs. queue: SQS queue jobs in us-west-2, account 123456789012. table: DynamoDB table orders in us-west-2, account 123456789012.
{
"function": "arn:aws:lambda:us-east-1:123456789012:function:resize",
"role": "arn:aws:iam::123456789012:role/deployer",
"object": "arn:aws:s3:::acme-logs/logs/app.txt",
"queue": "arn:aws:sqs:us-west-2:123456789012:jobs",
"table": "arn:aws:dynamodb:us-west-2:123456789012:table/orders"
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
arns: Return a JSON object with these keys, each holding the corresponding ARN. function: Lambda function resize in us-east-1, account 123456789012. role: IAM role deployer in account 123456789012. object: the object logs/app.txt in S3 bucket acme-logs. queue: SQS queue jobs in us-west-2, account 123456789012. table: DynamoDB table orders in us-west-2, account 123456789012.
{
"function": "arn:aws:lambda:us-east-1:123456789012:function:resize",
"role": "arn:aws:iam::123456789012:role/deployer",
"object": "arn:aws:s3:::acme-logs/logs/app.txt",
"queue": "arn:aws:sqs:us-west-2:123456789012:jobs",
"table": "arn:aws:dynamodb:us-west-2:123456789012:table/orders"
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
arns: Return a JSON object with these keys, each holding the corresponding ARN. function: Lambda function resize in us-east-1, account 123456789012. role: IAM role deployer in account 123456789012. object: the object logs/app.txt in S3 bucket acme-logs. queue: SQS queue jobs in us-west-2, account 123456789012. table: DynamoDB table orders in us-west-2, account 123456789012.
{
"function": "arn:aws:lambda:us-east-1:123456789012:function:resize",
"role": "arn:aws:iam::123456789012:role/deployer",
"object": "arn:aws:s3:::acme-logs/logs/app.txt",
"queue": "arn:aws:sqs:us-west-2:123456789012:jobs",
"table": "arn:aws:dynamodb:us-west-2:123456789012:table/orders"
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
subnets: A VPC has the CIDR block 10.20.0.0/16. Return a JSON array of 4 non-overlapping subnet CIDR blocks of equal size within this VPC. Each subnet must have at least 510 IP addresses that instances can use, and the blocks must be the smallest size that meets this requirement in AWS.
[
"10.20.0.0/22",
"10.20.4.0/22",
"10.20.8.0/22",
"10.20.12.0/22"
]
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
subnets: A VPC has the CIDR block 10.20.0.0/16. Return a JSON array of 4 non-overlapping subnet CIDR blocks of equal size within this VPC. Each subnet must have at least 510 IP addresses that instances can use, and the blocks must be the smallest size that meets this requirement in AWS.
[
"10.20.0.0/23",
"10.20.2.0/23",
"10.20.4.0/23",
"10.20.6.0/23"
]
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
subnets: A VPC has the CIDR block 10.20.0.0/16. Return a JSON array of 4 non-overlapping subnet CIDR blocks of equal size within this VPC. Each subnet must have at least 510 IP addresses that instances can use, and the blocks must be the smallest size that meets this requirement in AWS.
[
"10.20.0.0/22",
"10.20.64.0/22",
"10.20.128.0/22",
"10.20.192.0/22"
]
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
lifecycle: Return the S3 lifecycle configuration in the format accepted by the AWS CLI for --lifecycle-configuration, with one enabled rule for objects under the prefix logs/. The rule moves objects to Standard-IA after 30 days and to Glacier Flexible Retrieval after 90 days, deletes them after 365 days, and aborts incomplete multipart uploads after 7 days.
{
"Rules": [
{
"Id": "LogRetention",
"Status": "Enabled",
"Filter": {
"Prefix": "logs/"
},
"Transitions": [
{
"Days": 30,
"StorageClass": "STANDARD_IA"
},
{
"Days": 90,
"StorageClass": "GLACIER_FLEXIBLE_RETRIEVAL"
}
],
"Expiration": {
"Days": 365
},
"AbortMultipartUpload": {
"Days": 7
}
}
]
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
lifecycle: Return the S3 lifecycle configuration in the format accepted by the AWS CLI for --lifecycle-configuration, with one enabled rule for objects under the prefix logs/. The rule moves objects to Standard-IA after 30 days and to Glacier Flexible Retrieval after 90 days, deletes them after 365 days, and aborts incomplete multipart uploads after 7 days.
{
"Rules": [
{
"Id": "logs-lifecycle-rule",
"Status": "Enabled",
"Filter": {
"Prefix": "logs/"
},
"Transitions": [
{
"Days": 30,
"StorageClass": "STANDARD_IA"
},
{
"Days": 90,
"StorageClass": "GLACIER_FLEXIBLE_RETRIEVAL"
}
],
"Expiration": {
"Days": 365
},
"AbortMultipartUpload": {
"Days": 7
}
}
]
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
lifecycle: Return the S3 lifecycle configuration in the format accepted by the AWS CLI for --lifecycle-configuration, with one enabled rule for objects under the prefix logs/. The rule moves objects to Standard-IA after 30 days and to Glacier Flexible Retrieval after 90 days, deletes them after 365 days, and aborts incomplete multipart uploads after 7 days.
{
"LifecycleConfiguration": {
"Rules": [
{
"Id": "logs-rule",
"Status": "Enabled",
"Filter": {
"Prefix": "logs/"
},
"Transitions": [
{
"Days": 30,
"StorageClass": "STANDARD_IA"
},
{
"Days": 90,
"StorageClass": "GLACIER"
}
],
"Expiration": {
"Days": 365
},
"AbortIncompleteMultipartUpload": {
"DaysAfterInitiation": 7
}
}
]
}
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
trust: Write the trust policy of an IAM role so that any principal in account 111122223333 can assume it, and only when the request provides the external ID acme-42.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111122223333:*"
},
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": {
"sts:ExternalID": "acme-42"
}
}
}
]
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
trust: Write the trust policy of an IAM role so that any principal in account 111122223333 can assume it, and only when the request provides the external ID acme-42.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111122223333:*"
},
"Action": "sts:AssumeRole",
"Condition": {
"StringEquals": {
"sts:ExternalId": "acme-42"
}
}
}
]
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
trust: Write the trust policy of an IAM role so that any principal in account 111122223333 can assume it, and only when the request provides the external ID acme-42.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111122223333:*"
},
"Condition": {
"StringEquals": {
"sts:ExternalId": "acme-42"
}
}
}
]
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
query: Return a DynamoDB Query request in the format accepted by the AWS CLI for --cli-input-json. The table Orders has partition key pk and sort key sk, both strings. Fetch the items where pk is USER#42, sk starts with ORDER#2026, and the string attribute status is SHIPPED, with the highest sort keys first.
{
"TableName": "Orders",
"KeyConditionExpression": "pk = :pkVal AND begins_with(sk, :skVal)",
"FilterExpression": "status = :statusVal",
"ExpressionAttributeValues": {
":pkVal": { "S": "USER#42" },
":skVal": { "S": "ORDER#2026" },
":statusVal": { "S": "SHIPPED" }
},
"ScanIndexForward": false
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
query: Return a DynamoDB Query request in the format accepted by the AWS CLI for --cli-input-json. The table Orders has partition key pk and sort key sk, both strings. Fetch the items where pk is USER#42, sk starts with ORDER#2026, and the string attribute status is SHIPPED, with the highest sort keys first.
{
"TableName": "Orders",
"KeyConditionExpression": "(pk = :pk) AND (sk begins_with :sk)",
"FilterExpression": "status = :status",
"ExpressionAttributeValues": [
{
"Name": ":pk",
"Value": {
"S": "USER#42"
}
},
{
"Name": ":sk",
"Value": {
"S": "ORDER#2026"
}
},
{
"Name": ":status",
"Value": {
"S": "SHIPPED"
}
}
],
"ScanIndexForward": false
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
query: Return a DynamoDB Query request in the format accepted by the AWS CLI for --cli-input-json. The table Orders has partition key pk and sort key sk, both strings. Fetch the items where pk is USER#42, sk starts with ORDER#2026, and the string attribute status is SHIPPED, with the highest sort keys first.
{
"TableName": "Orders",
"KeyConditionExpression": "pk = :pk AND sk begins_with (:sk)",
"FilterExpression": "status = :status",
"ExpressionAttributeValues": {
":pk": "USER#42",
":sk": "ORDER#2026",
":status": "SHIPPED"
},
"ScanIndexForward": false
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
require-mfa: Write an IAM identity policy that allows ec2:* on all resources, except that ec2:TerminateInstances is denied unless the request was authenticated with MFA, regardless of the type of credentials the caller used.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "ec2:*",
"Resource": "*"
},
{
"Effect": "Deny",
"Action": "ec2:TerminateInstances",
"Resource": "*",
"Condition": {
"Bool": {
"aws:MultiFactorAuthPresent": "false"
}
}
}
]
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
require-mfa: Write an IAM identity policy that allows ec2:* on all resources, except that ec2:TerminateInstances is denied unless the request was authenticated with MFA, regardless of the type of credentials the caller used.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowEC2Actions",
"Effect": "Allow",
"Action": "ec2:*",
"Resource": "*"
},
{
"Sid": "DenyTerminateWithoutMFA",
"Effect": "Deny",
"Action": "ec2:TerminateInstances",
"Resource": "*",
"Condition": {
"Bool": {
"aws:MultiFactorAuthPresent": "false"
}
}
}
]
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
require-mfa: Write an IAM identity policy that allows ec2:* on all resources, except that ec2:TerminateInstances is denied unless the request was authenticated with MFA, regardless of the type of credentials the caller used.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowEC2AllActions",
"Effect": "Allow",
"Action": "ec2:*",
"Resource": "*"
},
{
"Sid": "DenyTerminateInstancesWithoutMFA",
"Effect": "Deny",
"Action": "ec2:TerminateInstances",
"Resource": "*",
"Condition": {
"Bool": {
"aws:MultiFactorAuthPresent": "false"
}
}
}
]
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
event-pattern: Write an EventBridge event pattern that matches S3 "Object Created" events sent to EventBridge, restricted to the bucket acme-uploads, where the object key ends in .csv and the object size is greater than 0.
{
"source": "aws.s3",
"detail-type": "S3 Object Created",
"detail": {
"bucket": {
"name": [
"acme-uploads"
]
},
"object": {
"key": {
"suffix": ".csv"
},
"size": {
">": 0
}
}
}
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
event-pattern: Write an EventBridge event pattern that matches S3 "Object Created" events sent to EventBridge, restricted to the bucket acme-uploads, where the object key ends in .csv and the object size is greater than 0.
{
"source": [
"aws.s3"
],
"detail-type": [
"AWS S3 Object Created"
],
"resources": [
"arn:aws:s3:::acme-uploads"
],
"detail": {
"bucket": {
"name": {
"Equals": "acme-uploads"
}
},
"object": {
"key": {
"Pattern": ".*\\.csv$"
},
"size": {
"GreaterThan": 0
}
}
}
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
event-pattern: Write an EventBridge event pattern that matches S3 "Object Created" events sent to EventBridge, restricted to the bucket acme-uploads, where the object key ends in .csv and the object size is greater than 0.
{
"source": [
"aws.s3"
],
"detail-type": [
"AWS S3 Object Created"
],
"resources": [
"arn:aws:s3:::acme-uploads"
],
"detail": {
"key": {
"op": "EndsWith",
"value": ".csv"
},
"size": {
"op": "GreaterThan",
"value": 0
}
}
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
home-folder: Write a single IAM identity policy to attach to multiple IAM users. Each user may list only the keys under home/<their user name>/ in the S3 bucket acme-home, and may download and upload objects only under that prefix. The policy must grant no other permissions.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ListHomeFolder",
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::acme-home",
"Condition": {
"StringLike": {
"s3:Prefix": "home/${aws:PrincipalName}/*"
}
}
},
{
"Sid": "AccessHomeFolder",
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::acme-home/home/${aws:PrincipalName}/*"
]
}
]
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
home-folder: Write a single IAM identity policy to attach to multiple IAM users. Each user may list only the keys under home/<their user name>/ in the S3 bucket acme-home, and may download and upload objects only under that prefix. The policy must grant no other permissions.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket"
],
"Resource": "arn:aws:s3:::acme-home",
"Condition": {
"StringLike": {
"s3:prefix": "home/${aws:username}/"
}
}
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Resource": "arn:aws:s3:::acme-home/home/${aws:username}/*"
}
]
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
home-folder: Write a single IAM identity policy to attach to multiple IAM users. Each user may list only the keys under home/<their user name>/ in the S3 bucket acme-home, and may download and upload objects only under that prefix. The policy must grant no other permissions.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowHomeFolderAccess",
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetObject",
"s3:PutObject"
],
"Resource": [
"arn:aws:s3:::acme-home/home/*"
],
"Condition": {
"s3:prefix": {
"StringLike": "home/${{aws:username}}/*"
},
"s3:key": {
"StringLike": "home/${{aws:username}}/*"
}
}
}
]
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
effective-access: Role app in account 111122223333 makes requests in its own account, with no session policy. Its identity policy allows s3:* and dynamodb:GetItem on all resources. Its permissions boundary allows s3:GetObject, s3:PutObject, s3:DeleteObject, s3:ListBucket and dynamodb:* on all resources. The organization's SCP allows * on all resources and denies s3:DeleteObject. The S3 requests go to the bucket acme-data, whose bucket policy has one statement, denying s3:PutObject to all principals. Return a JSON object with the keys s3:GetObject, s3:PutObject, s3:DeleteObject, s3:GetBucketPolicy, s3:ListBucket and dynamodb:PutItem, each holding "Allow" or "Deny" for the resulting authorization decision.
{
"s3:GetObject": "Allow",
"s3:PutObject": "Deny",
"s3:DeleteObject": "Deny",
"s3:GetBucketPolicy": "Deny",
"s3:ListBucket": "Allow",
"dynamodb:PutItem": "Deny"
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
effective-access: Role app in account 111122223333 makes requests in its own account, with no session policy. Its identity policy allows s3:* and dynamodb:GetItem on all resources. Its permissions boundary allows s3:GetObject, s3:PutObject, s3:DeleteObject, s3:ListBucket and dynamodb:* on all resources. The organization's SCP allows * on all resources and denies s3:DeleteObject. The S3 requests go to the bucket acme-data, whose bucket policy has one statement, denying s3:PutObject to all principals. Return a JSON object with the keys s3:GetObject, s3:PutObject, s3:DeleteObject, s3:GetBucketPolicy, s3:ListBucket and dynamodb:PutItem, each holding "Allow" or "Deny" for the resulting authorization decision.
{
"s3:GetObject": "Allow",
"s3:PutObject": "Deny",
"s3:DeleteObject": "Deny",
"s3:GetBucketPolicy": "Deny",
"s3:ListBucket": "Allow",
"dynamodb:PutItem": "Deny"
}
Answer an AWS question with one ```json code block holding exactly what the question asks for, as strict JSON. Do not include comments or explanations. All ARNs use the aws partition.
effective-access: Role app in account 111122223333 makes requests in its own account, with no session policy. Its identity policy allows s3:* and dynamodb:GetItem on all resources. Its permissions boundary allows s3:GetObject, s3:PutObject, s3:DeleteObject, s3:ListBucket and dynamodb:* on all resources. The organization's SCP allows * on all resources and denies s3:DeleteObject. The S3 requests go to the bucket acme-data, whose bucket policy has one statement, denying s3:PutObject to all principals. Return a JSON object with the keys s3:GetObject, s3:PutObject, s3:DeleteObject, s3:GetBucketPolicy, s3:ListBucket and dynamodb:PutItem, each holding "Allow" or "Deny" for the resulting authorization decision.
{
"s3:GetObject": "Allow",
"s3:PutObject": "Deny",
"s3:DeleteObject": "Deny",
"s3:GetBucketPolicy": "Deny",
"s3:ListBucket": "Allow",
"dynamodb:PutItem": "Deny"
}