Skip to content

Commit

Permalink
Minor usage imporvements!
Browse files Browse the repository at this point in the history
* Adds `.DS_Store` to the `.gitignore` file - because mac
* Exposes domainName and dualStackDomainName on the S3 L2 construct (because somtimes you need those)
* Adds a "Canonical User Id" in the permissions lib - because there's so many ways to identify accounts! (We need it for CloudFront OAIs 🎉)
  • Loading branch information
mindstorms6 committed May 31, 2018
1 parent 13d8b7f commit eb6b5da
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
node_modules
lerna-debug.log
*.js
Expand Down
4 changes: 4 additions & 0 deletions packages/aws-cdk-s3/lib/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ export interface BucketProps {
export class Bucket extends BucketRef {
public readonly bucketArn: s3.BucketArn;
public readonly bucketName: BucketName;
public readonly domainName: s3.BucketDomainName;
public readonly dualstackDomainName: s3.BucketDualStackDomainName;
public readonly encryptionKey?: kms.EncryptionKeyRef;
protected policy?: BucketPolicy;
protected autoCreatePolicy = true;
Expand Down Expand Up @@ -281,6 +283,8 @@ export class Bucket extends BucketRef {
this.encryptionKey = encryptionKey;
this.bucketArn = resource.bucketArn;
this.bucketName = resource.ref;
this.domainName = resource.bucketDomainName;
this.dualstackDomainName = resource.bucketDualStackDomainName;

// Add all lifecycle rules
(props.lifecycleRules || []).forEach(this.addLifecycleRule.bind(this));
Expand Down
23 changes: 23 additions & 0 deletions packages/aws-cdk/lib/cloudformation/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,29 @@ export class ServicePrincipal extends PolicyPrincipal {
}
}

/**
* A policy prinicipal for canonicalUserIds - useful for S3 bucket policies that use
* Origin Access identities.
*
* See https://docs.aws.amazon.com/general/latest/gr/acct-identifiers.html
*
* and
*
* https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html
*
* for more details.
*
*/
export class CanonicalUserPrincipal extends PolicyPrincipal {
constructor(public readonly canonicalUserId: any) {
super();
}

public toJson(): any {
return { CanonicalUser: this.canonicalUserId };
}
}

export class FederatedPrincipal extends PolicyPrincipal {
constructor(public readonly federated: any) {
super();
Expand Down

0 comments on commit eb6b5da

Please sign in to comment.