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'));