Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. ```ts
  2. "use strict";
  3. const pulumi = require("@pulumi/pulumi");
  4. const aws = require("@pulumi/aws");
  5. const awsx = require("@pulumi/awsx");
  6.  
  7. //* Create Kinesis stream for ingestion
  8. const ingestStream = new aws.kinesis.Stream("ingestAssets", {
  9. shardCount: 1,
  10. retentionPeriod: 72
  11. });
  12.  
  13. //* Create IoT Rule to push into Kinesis stream
  14. const iotRole = new aws.iam.Role("iotRole", {
  15. assumeRolePolicy: JSON.stringify({
  16. Version: "2012-10-17",
  17. Statement: [
  18. {
  19. Effect: "Allow",
  20. Principal: {
  21. Service: "iot.amazonaws.com"
  22. },
  23. Action: "sts:AssumeRole"
  24. }
  25. ]
  26. })
  27. });
  28.  
  29. const iotRolePolicy = new aws.iam.RolePolicy("iotRolePolicy", {
  30. policy: pulumi.interpolate`{
  31. "Version": "2012-10-17",
  32. "Statement": [
  33. {
  34. "Effect": "Allow",
  35. "Action": [
  36. "kinesis:*"
  37. ],
  38. "Resource": "${ingestStream.arn}"
  39. }
  40. ]
  41. }`,
  42. role: iotRole.id
  43. });
  44.  
  45. const iotRule = new aws.iot.TopicRule("iotTrigger", {
  46. description: "Pass from IoT Core to Asset Tracking",
  47. name: "iotAssetIngest",
  48. enabled: true,
  49. kinesis: {
  50. partitionKey: "id",
  51. roleArn: iotRole.arn,
  52. streamName: ingestStream.name
  53. },
  54. sql: "SELECT * FROM 'topic'",
  55. sqlVersion: "2015-10-08"
  56. });
  57. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement