Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into dev-benisrae
Browse files Browse the repository at this point in the history
  • Loading branch information
Elad Ben-Israel committed Jun 3, 2018
2 parents bfbb88b + dfc3da1 commit c46d14c
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.vscode
.DS_Store
node_modules
lerna-debug.log
dist
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"lerna": "2.5.1",
"packages": [
"packages/**/*",
"packages/*",
"examples"
],
"rejectCycles": "true",
Expand Down
3 changes: 3 additions & 0 deletions packages/aws-cdk-docs/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
coverage
.nyc_output
*.tgz
/*
!/dist/docs
/dist/staging
4 changes: 4 additions & 0 deletions packages/aws-cdk-java/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
coverage
.nyc_output
*.tgz
/*
!/target
/target/*
!/target/*.jar
2 changes: 1 addition & 1 deletion packages/aws-cdk-java/generate.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
set -euo pipefail
outdir="src/main"
outdir="src/main/java"
rm -fr "${outdir}"
for p in $(find-jsii-packages -k jsii.names.java); do
echo "Generating java code for module $p"
Expand Down
31 changes: 31 additions & 0 deletions packages/aws-cdk-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<artifactId>aws-cdk</artifactId>
<version>0.6</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
Expand All @@ -20,7 +24,34 @@
<target>1.8</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

<resources>
<resource>
<filtering>false</filtering>
<directory>src/main/java</directory>
<includes>
<include>**/assembly.jsii</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
</build>

<dependencies>
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
2 changes: 2 additions & 0 deletions packages/aws-cdk-toolkit/lib/api/aws-auth/credentials.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { CredentialProviderChain } from 'aws-sdk';

export { CredentialProviderChain };

export enum Mode {
ForReading,
ForWriting
Expand Down
1 change: 1 addition & 0 deletions packages/aws-cdk-toolkit/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"target":"ES2018",
"module": "commonjs",
"lib": ["es2016", "es2017.object", "es2017.string"],
"declaration": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
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
15 changes: 14 additions & 1 deletion packages/aws-cdk/test/cloudformation/test.perms.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Test } from 'nodeunit';
import { FnConcat, PolicyDocument, PolicyStatement, resolve } from '../../lib';
import { CanonicalUserPrincipal, FnConcat, PolicyDocument, PolicyStatement, resolve } from '../../lib';

export = {
'the Permission class is a programming model for iam'(test: Test) {
Expand Down Expand Up @@ -91,6 +91,19 @@ export = {
test.done();
},

'canonicalUserPrincipal adds a principal to a policy with the passed canonical user id'(test: Test) {
const p = new PolicyStatement();
const canoncialUser = "averysuperduperlongstringfor";
p.addPrincipal(new CanonicalUserPrincipal(canoncialUser));
test.deepEqual(resolve(p), {
Effect: "Allow",
Principal: {
CanonicalUser: canoncialUser
}
});
test.done();
},

'addAccountRootPrincipal adds a principal with the current account root'(test: Test) {
const p = new PolicyStatement();
p.addAccountRootPrincipal();
Expand Down

0 comments on commit c46d14c

Please sign in to comment.