Skip to content

Commit

Permalink
Merge pull request #390 from asfadmin/devel
Browse files Browse the repository at this point in the history
Allow S3 access originating from inside the VPC.
  • Loading branch information
mckadesorensen authored Aug 31, 2021
2 parents d29f639 + 821a9ec commit 12aca42
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions cloudformation/thin-egress-app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ Resources:
iam_role_name: !Ref DownloadRoleInRegion
policy_name: !Sub "${AWS::StackName}-IamPolicyDownload"
prefix: !Sub "${BucketnamePrefix}"
vpcid: !Sub "${PrivateVPC}"
Timeout: !Ref LambdaTimeout
Handler: update_lambda.lambda_handler
Runtime: 'python3.7'
Expand Down
18 changes: 18 additions & 0 deletions lambda/update_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def get_region_cidrs(current_region):


def get_base_policy(prefix):
vpcid = os.getenv('vpcid')
policy = """
{
Expand All @@ -77,6 +78,23 @@ def get_base_policy(prefix):
""" + f'"arn:aws:s3:::{prefix}' + """*"
],
"Effect": "Allow"
},
{
"Action": [
"s3:GetObject",
"s3:ListBucket",
"s3:GetBucketLocation"
],
"Resource": [
""" + f'"arn:aws:s3:::{prefix}' + """*/*",
""" + f'"arn:aws:s3:::{prefix}' + """*"
],
"Effect": "Allow",
"Condition": {
"StringEquals": {
"aws:SourceVpc": """ + f'"{vpcid}"' + """
}
}
}
]
}
Expand Down

0 comments on commit 12aca42

Please sign in to comment.