My AWS Notebook
Topics
App --- (sts:AssumeRole) --> Role
App <-- (Temp credentials) <-- Role
Explicit Deny -> Explicit Allow -> Implicit Deny
sts:AssumeRole
.There are 3 ways to provide access to a S3 bucket (Account A) from another AWS account (Account B).
"Effect": "Allow",
"Principal": {"AWS": "arn:aws:iam::AccountB:user/AccountBUserName"},
"Action": ["s3:GetObject", "s3:PutObject", "s3:PutObjectAcl"],
"Resource": "arn:aws:s3:::AccountABucketName/*"
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject", "s3:PutObjectAcl"],
"Resource": "arn:aws:s3:::AccountABucketName/*"
"Effect": "Allow",
"Principal": {"AWS": "arn:aws:iam::AccountB:user/AccountBUserName"},
"Action": "sts:AssumeRole"
"Statement": [
{
"Action": ["s3:ListAllMyBuckets"],
"Effect": "Allow",
"Resource": "arn:aws:s3:::*"
},
{
"Action": ["s3:ListBucket", "s3:GetBucketLocation"],
"Effect": "Allow",
"Resource": "arn:aws:s3:::AccountABucketName"
},
{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::AccountABucketName/*"
}
]
"Effect": "Allow",
"Action": "sts:AssumeRole",
"Resource": "arn:aws:iam::AccountA:role/AccountARole"
You can also grant cross-account permissions using the Lambda function policy.
aws lambda add-permission \
--region region \
--function-name helloworld \
--principal 111111111111 \
--action lambda_InvokeFunction
Cognito with API Gateway
IdP (token) -> Cognito IP (AWS credentials) -> APIG (IAM or Cognito UP Authorizer)
Cognito UP (token) -> Cognito IP (AWS credentials) -> APIG (IAM or Cognito UP Authorizer)
Cognito UP (JWT) ----------------------------------> APIG (IAM or Cognito UP Authorizer)