Skip to content

Commit

Permalink
Added Managed SSM Policy to Agent instance role (#117)
Browse files Browse the repository at this point in the history
Signed-off-by: Rishabh Singh <[email protected]>
  • Loading branch information
rishabh6788 authored May 12, 2022
1 parent 83a6200 commit 6e31574
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/compute/agent-node-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

import { CfnInstanceProfile, ServicePrincipal, Role } from '@aws-cdk/aws-iam';
import { CfnInstanceProfile, ServicePrincipal, Role, ManagedPolicy } from '@aws-cdk/aws-iam';
import { Fn, Stack, Tags } from '@aws-cdk/core';
import { KeyPair } from 'cdk-ec2-key-pair';
import { readFileSync } from 'fs';
Expand Down Expand Up @@ -44,6 +44,7 @@ export class AgentNodeConfig {
const AgentNodeRole = new Role(stack, 'JenkinsAgentNodeRole', {
assumedBy: new ServicePrincipal('ec2.amazonaws.com'),
});
AgentNodeRole.addManagedPolicy(ManagedPolicy.fromAwsManagedPolicyName('AmazonSSMManagedInstanceCore'));
const AgentNodeInstanceProfile = new CfnInstanceProfile(stack, 'JenkinsAgentNodeInstanceProfile', { roles: [AgentNodeRole.roleName] });
this.AgentNodeInstanceProfileArn = AgentNodeInstanceProfile.attrArn.toString();
this.SSHEC2KeySecretId = Fn.join('/', ['ec2-ssh-key', key.keyPairName.toString(), 'private']);
Expand Down

0 comments on commit 6e31574

Please sign in to comment.