in packages/utilities/s3-bucketpolicy-helper/lib/index.ts [95:148]
constructor(props: IRestrictObjectPrefixToRoles) {
this._formattedPrefix = '/' + this.formatS3Prefix(props.s3Prefix) + '/*';
// Covers our case where two / get resolved because our prefix is actually /
this._formattedPrefix = this._formattedPrefix.replace(/\/\//, '/');
// FEDERATED / READ
if (props.readRoleIds != undefined && props.readRoleIds.length > 0) {
// Construct our User:Id roles for read
const statement = this._readStatementScaffold(props);
statement.addCondition('StringLike', { 'aws:userId': props.readRoleIds.map(x => `${x}:*`) });
statement.addAnyPrincipal();
this._readStatements.push(statement);
}
// FEDERATED / READWRITE
if (props.readWriteRoleIds != undefined && props.readWriteRoleIds.length > 0) {
const statement = this._readWriteStatementScaffold(props);
statement.addCondition('StringLike', { 'aws:userId': props.readWriteRoleIds.map(x => `${x}:*`) });
statement.addAnyPrincipal();
this._readWriteStatements.push(statement);
}
// FEDERATED / READWRITESUPER
if (props.readWriteSuperRoleIds != undefined && props.readWriteSuperRoleIds.length > 0) {
const statement = this._readWriteSuperStatementScaffold(props);
statement.addCondition('StringLike', { 'aws:userId': props.readWriteSuperRoleIds.map(x => `${x}:*`) });
statement.addAnyPrincipal();
this._readWriteSuperStatements.push(statement);
}
// NONFEDERATED / READ
if (props.readPrincipals != undefined && props.readPrincipals.length > 0) {
const statement = this._readStatementScaffold(props);
props.readPrincipals.forEach(principal => {
statement.addPrincipals(principal);
});
this._readStatements.push(statement);
}
// NONFEDERATED / READWRITE
if (props.readWritePrincipals != undefined && props.readWritePrincipals.length > 0) {
const statement = this._readWriteStatementScaffold(props);
props.readWritePrincipals.forEach(principal => {
statement.addPrincipals(principal);
});
this._readWriteStatements.push(statement);
}
// NONFEDERATED / READWRITESUPER
if (props.readWriteSuperPrincipals != undefined && props.readWriteSuperPrincipals.length > 0) {
const statement = this._readWriteSuperStatementScaffold(props);
props.readWriteSuperPrincipals.forEach(principal => {
statement.addPrincipals(principal);
});
this._readWriteSuperStatements.push(statement);
}
}