From 2eccdf72a9ccf8ab4677a64231d1dc6b37ab2e7e Mon Sep 17 00:00:00 2001 From: Taylor Ondrey <2449193+maafk@users.noreply.github.com> Date: Wed, 15 Sep 2021 15:17:07 -0400 Subject: [PATCH] fix(aws-ec2): set proper role for --role argument --- packages/@aws-cdk/aws-ec2/lib/cfn-init.ts | 2 +- packages/@aws-cdk/aws-ec2/test/cfn-init.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/@aws-cdk/aws-ec2/lib/cfn-init.ts b/packages/@aws-cdk/aws-ec2/lib/cfn-init.ts index 78b3345743347..9183ae15100cc 100644 --- a/packages/@aws-cdk/aws-ec2/lib/cfn-init.ts +++ b/packages/@aws-cdk/aws-ec2/lib/cfn-init.ts @@ -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; diff --git a/packages/@aws-cdk/aws-ec2/test/cfn-init.test.ts b/packages/@aws-cdk/aws-ec2/test/cfn-init.test.ts index e2539b71ac223..9b2cde4b678bb 100644 --- a/packages/@aws-cdk/aws-ec2/test/cfn-init.test.ts +++ b/packages/@aws-cdk/aws-ec2/test/cfn-init.test.ts @@ -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'));