Skip to content

Commit

Permalink
fix(ec2): set proper role for --role argument of cfn-init (#16503)
Browse files Browse the repository at this point in the history
closes #16501 
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
maafk authored Sep 21, 2021
1 parent ac503cb commit cdbd65d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-ec2/lib/cfn-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class CloudFormationInit {
resourceLocator = `${resourceLocator} --url https://cloudformation.${Aws.REGION}.${Aws.URL_SUFFIX}`;
}
if (attachOptions.includeRole) {
resourceLocator = `${resourceLocator} --role ${attachOptions.instanceRole}`;
resourceLocator = `${resourceLocator} --role ${attachOptions.instanceRole.roleName}`;
}
const configSets = (attachOptions.configSets ?? ['default']).join(',');
const printLog = attachOptions.printLog ?? true;
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-ec2/test/cfn-init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@ describe('userdata', () => {
expectLine(lines, cmdArg('cfn-init', `--region ${Aws.REGION}`));
expectLine(lines, cmdArg('cfn-init', `--stack ${Aws.STACK_NAME}`));
expectLine(lines, cmdArg('cfn-init', `--resource ${resource.logicalId}`));
expectLine(lines, cmdArg('cfn-init', `--role ${instanceRole}`));
expectLine(lines, cmdArg('cfn-init', `--role ${instanceRole.roleName}`));
expectLine(lines, cmdArg('cfn-init', `--url https://cloudformation.${Aws.REGION}.${Aws.URL_SUFFIX}`));
expectLine(lines, cmdArg('cfn-init', '-c default'));
expectLine(lines, cmdArg('cfn-signal', `--region ${Aws.REGION}`));
expectLine(lines, cmdArg('cfn-signal', `--stack ${Aws.STACK_NAME}`));
expectLine(lines, cmdArg('cfn-signal', `--resource ${resource.logicalId}`));
expectLine(lines, cmdArg('cfn-init', `--role ${instanceRole}`));
expectLine(lines, cmdArg('cfn-init', `--role ${instanceRole.roleName}`));
expectLine(lines, cmdArg('cfn-init', `--url https://cloudformation.${Aws.REGION}.${Aws.URL_SUFFIX}`));
expectLine(lines, cmdArg('cfn-signal', '-e $?'));
expectLine(lines, cmdArg('cat', 'cfn-init.log'));
Expand Down

0 comments on commit cdbd65d

Please sign in to comment.