Skip to content

Commit

Permalink
arnFromComponents() -> formatArn()
Browse files Browse the repository at this point in the history
  • Loading branch information
rix0rrr committed Jan 8, 2019
1 parent d1a643e commit 12854e6
Show file tree
Hide file tree
Showing 20 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/integrations/aws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class AwsIntegration extends Integration {
integrationHttpMethod: 'POST',
uri: new cdk.Token(() => {
if (!this.scope) { throw new Error('AwsIntegration must be used in API'); }
return cdk.Stack.find(this.scope).arnFromComponents({
return cdk.Stack.find(this.scope).formatArn({
service: 'apigateway',
account: backend,
resource: apiType,
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export class Method extends cdk.Construct {
} else if (options.credentialsPassthrough) {
// arn:aws:iam::*:user/*
// tslint:disable-next-line:max-line-length
credentials = cdk.Stack.find(this).arnFromComponents({ service: 'iam', region: '', account: '*', resource: 'user', sep: '/', resourceName: '*' });
credentials = cdk.Stack.find(this).formatArn({ service: 'iam', region: '', account: '*', resource: 'user', sep: '/', resourceName: '*' });
}

return {
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-apigateway/lib/restapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export class RestApi extends cdk.Construct implements cdk.IDependable, IRestApi
method = '*';
}

return cdk.Stack.find(this).arnFromComponents({
return cdk.Stack.find(this).formatArn({
service: 'execute-api',
resource: this.restApiId,
sep: '/',
Expand Down Expand Up @@ -358,7 +358,7 @@ export class RestApi extends cdk.Construct implements cdk.IDependable, IRestApi
private configureCloudWatchRole(apiResource: CfnRestApi) {
const role = new iam.Role(this, 'CloudWatchRole', {
assumedBy: new iam.ServicePrincipal('apigateway.amazonaws.com'),
managedPolicyArns: [ cdk.Stack.find(this).arnFromComponents({
managedPolicyArns: [ cdk.Stack.find(this).formatArn({
service: 'iam',
region: '',
account: 'aws',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ class SingletonPolicy extends cdk.Construct {
}

private stackArnFromProps(props: { stackName: string, region?: string }): string {
return cdk.Stack.find(this).arnFromComponents({
return cdk.Stack.find(this).formatArn({
region: props.region,
service: 'cloudformation',
resource: 'stack',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ function _isOrContains(entity: string | string[], value: string): boolean {
}

function _stackArn(stackName: string, scope: cdk.IConstruct): string {
return cdk.Stack.find(scope).arnFromComponents({
return cdk.Stack.find(scope).formatArn({
service: 'cloudformation',
resource: 'stack',
resourceName: `${stackName}/*`,
Expand All @@ -287,7 +287,7 @@ class PipelineDouble extends cdk.Construct implements cpapi.IPipeline {
constructor(scope: cdk.Construct, id: string, { pipelineName, role }: { pipelineName?: string, role: iam.Role }) {
super(scope, id);
this.pipelineName = pipelineName || 'TestPipeline';
this.pipelineArn = cdk.Stack.find(this).arnFromComponents({ service: 'codepipeline', resource: 'pipeline', resourceName: this.pipelineName });
this.pipelineArn = cdk.Stack.find(this).formatArn({ service: 'codepipeline', resource: 'pipeline', resourceName: this.pipelineName });
this.role = role;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-codebuild/lib/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class ImportedProject extends ProjectBase {
constructor(scope: cdk.Construct, id: string, private readonly props: ProjectImportProps) {
super(scope, id);

this.projectArn = cdk.Stack.find(this).arnFromComponents({
this.projectArn = cdk.Stack.find(this).formatArn({
service: 'codebuild',
resource: 'project',
resourceName: props.projectName,
Expand Down Expand Up @@ -771,7 +771,7 @@ export class Project extends ProjectBase {
}

private createLoggingPermission() {
const logGroupArn = cdk.Stack.find(this).arnFromComponents({
const logGroupArn = cdk.Stack.find(this).formatArn({
service: 'logs',
resource: 'log-group',
sep: ':',
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codecommit/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class ImportedRepository extends RepositoryBase {
constructor(scope: cdk.Construct, id: string, private readonly props: RepositoryImportProps) {
super(scope, id);

this.repositoryArn = cdk.Stack.find(this).arnFromComponents({
this.repositoryArn = cdk.Stack.find(this).formatArn({
service: 'codecommit',
resource: props.repositoryName,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codedeploy/lib/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class ServerApplication extends cdk.Construct implements IServerApplicati
}

function applicationNameToArn(applicationName: string, scope: cdk.IConstruct): string {
return cdk.Stack.find(scope).arnFromComponents({
return cdk.Stack.find(scope).formatArn({
service: 'codedeploy',
resource: 'application',
resourceName: applicationName,
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codedeploy/lib/deployment-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export class ServerDeploymentConfig extends cdk.Construct implements IServerDepl
}

function arnForDeploymentConfigName(name: string, scope: cdk.IConstruct): string {
return cdk.Stack.find(scope).arnFromComponents({
return cdk.Stack.find(scope).formatArn({
service: 'codedeploy',
resource: 'deploymentconfig',
resourceName: name,
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codedeploy/lib/deployment-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupBase {
}

function deploymentGroupNameToArn(applicationName: string, deploymentGroupName: string, scope: cdk.IConstruct): string {
return cdk.Stack.find(scope).arnFromComponents({
return cdk.Stack.find(scope).formatArn({
service: 'codedeploy',
resource: 'deploymentgroup',
resourceName: `${applicationName}/${deploymentGroupName}`,
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-codepipeline/lib/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class Pipeline extends cdk.Construct implements cpapi.IPipeline {
this.artifactStores = {};

// Does not expose a Fn::GetAtt for the ARN so we'll have to make it ourselves
this.pipelineArn = cdk.Stack.find(this).arnFromComponents({
this.pipelineArn = cdk.Stack.find(this).formatArn({
service: 'codepipeline',
resource: this.pipelineName
});
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-dynamodb/lib/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ export class Table extends Construct {
private makeScalingRole(): iam.IRole {
// Use a Service Linked Role.
return iam.Role.import(this, 'ScalingRole', {
roleArn: cdk.Stack.find(this).arnFromComponents({
roleArn: cdk.Stack.find(this).formatArn({
// https://docs.aws.amazon.com/autoscaling/application/userguide/application-auto-scaling-service-linked-roles.html
service: 'iam',
resource: 'role/aws-service-role/dynamodb.application-autoscaling.amazonaws.com',
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ecr/lib/repository-ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export abstract class RepositoryBase extends cdk.Construct implements IRepositor
* as the current stack.
*/
public static arnForLocalRepository(repositoryName: string, scope: cdk.IConstruct): string {
return cdk.Stack.find(scope).arnFromComponents({
return cdk.Stack.find(scope).formatArn({
service: 'ecr',
resource: 'repository',
resourceName: repositoryName
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ecs/lib/base/base-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export abstract class BaseService extends cdk.Construct
private makeAutoScalingRole(): iam.IRole {
// Use a Service Linked Role.
return iam.Role.import(this, 'ScalingRole', {
roleArn: cdk.Stack.find(this).arnFromComponents({
roleArn: cdk.Stack.find(this).formatArn({
service: 'iam',
resource: 'role/aws-service-role/ecs.application-autoscaling.amazonaws.com',
resourceName: 'AWSServiceRoleForApplicationAutoScaling_ECSService',
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-iam/lib/managed-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class AwsManagedPolicy {
*/
public get policyArn(): string {
// the arn is in the form of - arn:aws:iam::aws:policy/<policyName>
return cdk.Stack.find(this.scope).arnFromComponents({
return cdk.Stack.find(this.scope).formatArn({
service: "iam",
region: "", // no region for managed policy
account: "aws", // the account for a managed policy is 'aws'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class NotificationsResourceHandler extends cdk.Construct {
const role = new iam.Role(this, 'Role', {
assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),
managedPolicyArns: [
cdk.Stack.find(this).arnFromComponents({
cdk.Stack.find(this).formatArn({
service: 'iam',
region: '', // no region for managed policy
account: 'aws', // the account for a managed policy is 'aws'
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-s3/lib/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function parseBucketArn(construct: cdk.IConstruct, props: BucketImportPro
}

if (props.bucketName) {
return cdk.Stack.find(construct).arnFromComponents({
return cdk.Stack.find(construct).formatArn({
// S3 Bucket names are globally unique in a partition,
// and so their ARNs have empty region and account components
region: '',
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/cdk/lib/cloudformation/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export class Stack extends Construct {
* the 'scope' is attached to. If all ARN pieces are supplied, the supplied scope
* can be 'undefined'.
*/
public arnFromComponents(components: ArnComponents): string {
public formatArn(components: ArnComponents): string {
return arnFromComponents(components, this);
}

Expand Down
10 changes: 5 additions & 5 deletions packages/@aws-cdk/cdk/test/cloudformation/test.arn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export = {
'create from components with defaults'(test: Test) {
const stack = new Stack();

const arn = stack.arnFromComponents({
const arn = stack.formatArn({
service: 'sqs',
resource: 'myqueuename'
});
Expand All @@ -20,7 +20,7 @@ export = {
'create from components with specific values for the various components'(test: Test) {
const stack = new Stack();

const arn = stack.arnFromComponents({
const arn = stack.formatArn({
service: 'dynamodb',
resource: 'table',
account: '123456789012',
Expand All @@ -37,7 +37,7 @@ export = {
'allow empty string in components'(test: Test) {
const stack = new Stack();

const arn = stack.arnFromComponents({
const arn = stack.formatArn({
service: 's3',
resource: 'my-bucket',
account: '',
Expand All @@ -54,7 +54,7 @@ export = {
'resourcePathSep can be set to ":" instead of the default "/"'(test: Test) {
const stack = new Stack();

const arn = stack.arnFromComponents({
const arn = stack.formatArn({
service: 'codedeploy',
resource: 'application',
sep: ':',
Expand All @@ -71,7 +71,7 @@ export = {
'fails if resourcePathSep is neither ":" nor "/"'(test: Test) {
const stack = new Stack();

test.throws(() => stack.arnFromComponents({
test.throws(() => stack.formatArn({
service: 'foo',
resource: 'bar',
sep: 'x' }));
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/runtime-values/lib/rtv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class RuntimeValue extends cdk.Construct {
value: props.value,
});

this.parameterArn = cdk.Stack.find(this).arnFromComponents({
this.parameterArn = cdk.Stack.find(this).formatArn({
service: 'ssm',
resource: 'parameter',
resourceName: this.parameterName
Expand Down

0 comments on commit 12854e6

Please sign in to comment.