Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

Commit

Permalink
fix: use generated policy names
Browse files Browse the repository at this point in the history
So they can be updated
  • Loading branch information
coderbyheart committed Jul 24, 2019
1 parent 0f75122 commit 73f3b23
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cdk/stacks/Bifravst.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export class BifravstStack extends CloudFormation.Stack {
}),
],
}),
// This allows users to attach IoT policies to them-selves.
// They will attach the userIotPolicy (see below) so they can connect
// to the AWS IoT broker via MQTT.
attachPolicy: new IAM.PolicyDocument({
statements: [
new IAM.PolicyStatement({
Expand Down Expand Up @@ -163,8 +166,7 @@ export class BifravstStack extends CloudFormation.Stack {

// IoT Policy for Cognito user

new Iot.CfnPolicy(this, 'userIotPolicy', {
policyName: `${id}-userIotPolicy`,
const userIotPolicy = new Iot.CfnPolicy(this, 'userIotPolicy', {
policyDocument: {
Version: '2012-10-17',
Statement: [
Expand Down Expand Up @@ -196,9 +198,9 @@ export class BifravstStack extends CloudFormation.Stack {
},
})

new CloudFormation.CfnOutput(this, 'iotPolicy', {
value: `${id}-userIotPolicy`,
exportName: `${this.stackName}:iotPolicy`,
new CloudFormation.CfnOutput(this, 'userIotPolicyArn', {
value: userIotPolicy.attrArn,
exportName: `${this.stackName}:userIotPolicyArn`,
})

// Web App
Expand Down Expand Up @@ -258,7 +260,6 @@ export class BifravstStack extends CloudFormation.Stack {
})

const iotThingPolicy = new Iot.CfnPolicy(this, 'thingPolicy', {
policyName: `${id}-thingPolicy`,
policyDocument: {
Version: '2012-10-17',
Statement: [
Expand Down Expand Up @@ -358,4 +359,5 @@ export type StackOutputs = {
jitpRoleArn: string
thingPolicyArn: string
thingGroupName: string
userIotPolicyArn: string
}

0 comments on commit 73f3b23

Please sign in to comment.