Skip to content

Commit

Permalink
Revert "feat(cloudfront): import existing CloudFrontWebDistributions"
Browse files Browse the repository at this point in the history
This reverts commit 5f60ba5.
  • Loading branch information
njlynch committed Aug 27, 2020
1 parent 5f60ba5 commit 4db0a50
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 67 deletions.
16 changes: 2 additions & 14 deletions packages/@aws-cdk/aws-cloudfront/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ new cloudfront.Distribution(this, 'myDist', {
});
```

#### From an HTTP endpoint
## From an HTTP endpoint

Origins can also be created from any other HTTP endpoint, given the domain name, and optionally, other origin properties.

Expand Down Expand Up @@ -246,18 +246,6 @@ new cloudfront.Distribution(this, 'myDist', {
});
```

### Importing Distributions

Existing distributions can be imported as well; note that like most imported constructs, an imported distribution cannot be modified.
However, it can be used as a reference for other higher-level constructs.

```ts
const distribution = cloudfront.Distribution.fromDistributionAttributes(scope, 'ImportedDist', {
domainName: 'd111111abcdef8.cloudfront.net',
distributionId: '012345ABCDEF',
});
```

## CloudFrontWebDistribution API - Stable

![cdk-constructs: Stable](https://img.shields.io/badge/cdk--constructs-stable-success.svg?style=for-the-badge)
Expand Down Expand Up @@ -317,7 +305,7 @@ Example:

[create a distrubution with an iam certificate example](test/example.iam-cert-alias.lit.ts)

### Restrictions
#### Restrictions

CloudFront supports adding restrictions to your distribution.

Expand Down
40 changes: 0 additions & 40 deletions packages/@aws-cdk/aws-cloudfront/lib/web_distribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,27 +628,6 @@ interface BehaviorWithOrigin extends Behavior {
readonly targetOriginId: string;
}

/**
* Attributes used to import a Distribution.
*
* @experimental
*/
export interface CloudFrontWebDistributionAttributes {
/**
* The generated domain name of the Distribution, such as d111111abcdef8.cloudfront.net.
*
* @attribute
*/
readonly domainName: string;

/**
* The distribution ID for this distribution.
*
* @attribute
*/
readonly distributionId: string;
}

/**
* Amazon CloudFront is a global content delivery network (CDN) service that securely delivers data, videos,
* applications, and APIs to your viewers with low latency and high transfer speeds.
Expand Down Expand Up @@ -680,25 +659,6 @@ export interface CloudFrontWebDistributionAttributes {
* @resource AWS::CloudFront::Distribution
*/
export class CloudFrontWebDistribution extends cdk.Resource implements IDistribution {

/**
* Creates a construct that represents an external (imported) distribution.
*/
public static fromDistributionAttributes(scope: cdk.Construct, id: string, attrs: CloudFrontWebDistributionAttributes): IDistribution {
return new class extends cdk.Resource implements IDistribution {
public readonly domainName: string;
public readonly distributionDomainName: string;
public readonly distributionId: string;

constructor() {
super(scope, id);
this.domainName = attrs.domainName;
this.distributionDomainName = attrs.domainName;
this.distributionId = attrs.distributionId;
}
}();
}

/**
* The logging bucket for this CloudFront distribution.
* If logging is not enabled for this distribution - this property will be undefined.
Expand Down
13 changes: 0 additions & 13 deletions packages/@aws-cdk/aws-cloudfront/test/web_distribution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1288,17 +1288,4 @@ nodeunitShim({
},
},
},

'existing distributions can be imported'(test: Test) {
const stack = new cdk.Stack();
const dist = CloudFrontWebDistribution.fromDistributionAttributes(stack, 'ImportedDist', {
domainName: 'd111111abcdef8.cloudfront.net',
distributionId: '012345ABCDEF',
});

test.equals(dist.distributionDomainName, 'd111111abcdef8.cloudfront.net');
test.equals(dist.distributionId, '012345ABCDEF');

test.done();
},
});

0 comments on commit 4db0a50

Please sign in to comment.