Skip to content

Commit

Permalink
fix(aws-s3): remove bucket name validation (#628)
Browse files Browse the repository at this point in the history
Now that Tokens can be stringified, they can be inserted into parameters
like `bucketName`, which can lead to an input string like
`"bucket-name-${Token[TOKEN.0]}"`. We can't properly validate these
strings anymore.

Fixes #624.
  • Loading branch information
rix0rrr authored Sep 3, 2018
1 parent 19b540a commit d255953
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
4 changes: 1 addition & 3 deletions packages/@aws-cdk/aws-s3/lib/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import perms = require('./perms');
import { CommonPipelineSourceProps, PipelineSource } from './pipeline-action';
import { LifecycleRule } from './rule';
import { BucketArn, BucketDomainName, BucketDualStackDomainName, BucketName, cloudformation } from './s3.generated';
import { parseBucketArn, parseBucketName, validateBucketName } from './util';
import { parseBucketArn, parseBucketName } from './util';

/**
* A reference to a bucket. The easiest way to instantiate is to call
Expand Down Expand Up @@ -367,8 +367,6 @@ export class Bucket extends BucketRef {
constructor(parent: cdk.Construct, name: string, props: BucketProps = {}) {
super(parent, name);

validateBucketName(props && props.bucketName);

const { bucketEncryption, encryptionKey } = this.parseEncryption(props);

const resource = new cloudformation.BucketResource(this, 'Resource', {
Expand Down
10 changes: 0 additions & 10 deletions packages/@aws-cdk/aws-s3/lib/util.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import { Arn } from '@aws-cdk/cdk';
import { BucketRefProps } from './bucket';

export function validateBucketName(bucketName?: string) {
if (!bucketName) {
return;
}

if (bucketName.search(/[^a-z0-9.-]/g) !== -1) {
throw new Error('Bucket name contains invalid characters: ' + bucketName);
}
}

export function parseBucketArn(props: BucketRefProps) {

// if we have an explicit bucket ARN, use it.
Expand Down

0 comments on commit d255953

Please sign in to comment.