-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started diff permissions for app v command
- Loading branch information
1 parent
122bc43
commit f85788c
Showing
7 changed files
with
92 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { PolicyStatement } from "aws-cdk-lib/aws-iam"; | ||
|
||
/** | ||
* Construct a list of PolicyStatement objects that give us the desired | ||
* access to a user specified data buckets object. | ||
* | ||
* @param arnPartition | ||
* @param dataBucketPaths | ||
*/ | ||
export function getPolicyStatementsFromDataBucketPaths( | ||
arnPartition: string, | ||
dataBucketPaths: { [bucket: string]: string[] } | ||
) { | ||
const stmts: PolicyStatement[] = []; | ||
|
||
// restrict our Get operations to a very specific set of keys in the named buckets | ||
for (const [bucketName, keyWildcards] of Object.entries(dataBucketPaths)) { | ||
stmts.push( | ||
new PolicyStatement({ | ||
actions: ["s3:GetObject"], | ||
// NOTE: we could consider restricting to region or account here in constructing the ARNS | ||
// but given the bucket names are already globally specific we leave them open | ||
resources: keyWildcards.map( | ||
(k) => `arn:${arnPartition}:s3:::${bucketName}/${k}` | ||
), | ||
}) | ||
); | ||
} | ||
|
||
stmts.push( | ||
new PolicyStatement({ | ||
actions: ["s3:ListBucket"], | ||
resources: Object.keys(dataBucketPaths).map( | ||
(b) => `arn:${arnPartition}:s3:::${b}` | ||
), | ||
}) | ||
); | ||
|
||
return stmts; | ||
} |