// Jest Snapshot v1, https://goo.gl/fbAQLP exports[`IoT Device Simulator SimulatorConstruct Test 1`] = ` { "Mappings": { "ServiceprincipalMap": { "af-south-1": { "states": "states.af-south-1.amazonaws.com", }, "ap-east-1": { "states": "states.ap-east-1.amazonaws.com", }, "ap-northeast-1": { "states": "states.ap-northeast-1.amazonaws.com", }, "ap-northeast-2": { "states": "states.ap-northeast-2.amazonaws.com", }, "ap-northeast-3": { "states": "states.ap-northeast-3.amazonaws.com", }, "ap-south-1": { "states": "states.ap-south-1.amazonaws.com", }, "ap-south-2": { "states": "states.ap-south-2.amazonaws.com", }, "ap-southeast-1": { "states": "states.ap-southeast-1.amazonaws.com", }, "ap-southeast-2": { "states": "states.ap-southeast-2.amazonaws.com", }, "ap-southeast-3": { "states": "states.ap-southeast-3.amazonaws.com", }, "ca-central-1": { "states": "states.ca-central-1.amazonaws.com", }, "cn-north-1": { "states": "states.cn-north-1.amazonaws.com", }, "cn-northwest-1": { "states": "states.cn-northwest-1.amazonaws.com", }, "eu-central-1": { "states": "states.eu-central-1.amazonaws.com", }, "eu-central-2": { "states": "states.eu-central-2.amazonaws.com", }, "eu-north-1": { "states": "states.eu-north-1.amazonaws.com", }, "eu-south-1": { "states": "states.eu-south-1.amazonaws.com", }, "eu-south-2": { "states": "states.eu-south-2.amazonaws.com", }, "eu-west-1": { "states": "states.eu-west-1.amazonaws.com", }, "eu-west-2": { "states": "states.eu-west-2.amazonaws.com", }, "eu-west-3": { "states": "states.eu-west-3.amazonaws.com", }, "me-central-1": { "states": "states.me-central-1.amazonaws.com", }, "me-south-1": { "states": "states.me-south-1.amazonaws.com", }, "sa-east-1": { "states": "states.sa-east-1.amazonaws.com", }, "us-east-1": { "states": "states.us-east-1.amazonaws.com", }, "us-east-2": { "states": "states.us-east-2.amazonaws.com", }, "us-gov-east-1": { "states": "states.us-gov-east-1.amazonaws.com", }, "us-gov-west-1": { "states": "states.us-gov-west-1.amazonaws.com", }, "us-iso-east-1": { "states": "states.amazonaws.com", }, "us-iso-west-1": { "states": "states.amazonaws.com", }, "us-isob-east-1": { "states": "states.amazonaws.com", }, "us-west-1": { "states": "states.us-west-1.amazonaws.com", }, "us-west-2": { "states": "states.us-west-2.amazonaws.com", }, }, }, "Resources": { "TestDTypeTableEB82FCB5": { "DeletionPolicy": "Retain", "Properties": { "AttributeDefinitions": [ { "AttributeName": "typeId", "AttributeType": "S", }, ], "KeySchema": [ { "AttributeName": "typeId", "KeyType": "HASH", }, ], "ProvisionedThroughput": { "ReadCapacityUnits": 5, "WriteCapacityUnits": 5, }, }, "Type": "AWS::DynamoDB::Table", "UpdateReplacePolicy": "Retain", }, "TestPolicyCC05E598": { "Properties": { "PolicyDocument": { "Statement": [ { "Action": "cloudwatch:Get*", "Effect": "Allow", "Resource": "*", }, ], "Version": "2012-10-17", }, "PolicyName": "TestPolicyCC05E598", "Roles": [ { "Ref": "simulatorEngineLambdaRoleE774CD29", }, { "Ref": "simulatorMicroservicesRole0AC1A17A", }, ], }, "Type": "AWS::IAM::Policy", }, "TestSimTable7336F78A": { "DeletionPolicy": "Retain", "Properties": { "AttributeDefinitions": [ { "AttributeName": "simId", "AttributeType": "S", }, ], "KeySchema": [ { "AttributeName": "simId", "KeyType": "HASH", }, ], "ProvisionedThroughput": { "ReadCapacityUnits": 5, "WriteCapacityUnits": 5, }, }, "Type": "AWS::DynamoDB::Table", "UpdateReplacePolicy": "Retain", }, "simulatorEngineLambda17530EFE": { "DependsOn": [ "simulatorEngineLambdaRoleDefaultPolicy9ECE33DE", "simulatorEngineLambdaRoleE774CD29", ], "Properties": { "Code": { "S3Bucket": "test-bucket-region", "S3Key": "testPrefix//simulator.zip", }, "Description": "IoT Device Simulator function", "Environment": { "Variables": { "IOT_ENDPOINT": "abcd123efg45h-ats.iot.some-region.amazonaws.com", "ROUTE_BUCKET": { "Ref": "testRouteBucket64D9BEB5", }, "SEND_ANONYMOUS_METRIC": "Yes", "SIM_TABLE": { "Ref": "TestSimTable7336F78A", }, "SOLUTION_ID": "testId", "UUID": "abc123", "VERSION": "testVersion", }, }, "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "simulatorEngineLambdaRoleE774CD29", "Arn", ], }, "Runtime": "nodejs18.x", "Timeout": 900, }, "Type": "AWS::Lambda::Function", }, "simulatorEngineLambdaRoleDefaultPolicy9ECE33DE": { "Properties": { "PolicyDocument": { "Statement": [ { "Action": [ "s3:GetObject*", "s3:GetBucket*", "s3:List*", ], "Effect": "Allow", "Resource": [ { "Fn::GetAtt": [ "testRouteBucket64D9BEB5", "Arn", ], }, { "Fn::Join": [ "", [ { "Fn::GetAtt": [ "testRouteBucket64D9BEB5", "Arn", ], }, "/*", ], ], }, ], }, ], "Version": "2012-10-17", }, "PolicyName": "simulatorEngineLambdaRoleDefaultPolicy9ECE33DE", "Roles": [ { "Ref": "simulatorEngineLambdaRoleE774CD29", }, ], }, "Type": "AWS::IAM::Policy", }, "simulatorEngineLambdaRoleE774CD29": { "Properties": { "AssumeRolePolicyDocument": { "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": "lambda.amazonaws.com", }, }, ], "Version": "2012-10-17", }, "Path": "/", "Policies": [ { "PolicyDocument": { "Statement": [ { "Action": "s3:GetObject", "Effect": "Allow", "Resource": { "Fn::GetAtt": [ "testRouteBucket64D9BEB5", "Arn", ], }, }, ], "Version": "2012-10-17", }, "PolicyName": "S3Policy", }, { "PolicyDocument": { "Statement": [ { "Action": "dynamodb:GetItem", "Effect": "Allow", "Resource": { "Fn::GetAtt": [ "TestSimTable7336F78A", "Arn", ], }, }, ], "Version": "2012-10-17", }, "PolicyName": "DynamoDBPolicy", }, { "PolicyDocument": { "Statement": [ { "Action": "iot:Publish", "Effect": "Allow", "Resource": { "Fn::Join": [ "", [ "arn:", { "Ref": "AWS::Partition", }, ":iot:", { "Ref": "AWS::Region", }, ":", { "Ref": "AWS::AccountId", }, ":topic/*", ], ], }, }, ], "Version": "2012-10-17", }, "PolicyName": "IoTPolicy", }, ], }, "Type": "AWS::IAM::Role", }, "simulatorMicroservicesRole0AC1A17A": { "Properties": { "AssumeRolePolicyDocument": { "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": "lambda.amazonaws.com", }, }, ], "Version": "2012-10-17", }, "Path": "/", "Policies": [ { "PolicyDocument": { "Statement": [ { "Action": [ "dynamodb:PutItem", "dynamodb:DeleteItem", "dynamodb:GetItem", "dynamodb:Scan", "dynamodb:Query", "dynamodb:BatchGetItem", ], "Effect": "Allow", "Resource": [ { "Fn::GetAtt": [ "TestSimTable7336F78A", "Arn", ], }, { "Fn::GetAtt": [ "TestDTypeTableEB82FCB5", "Arn", ], }, ], }, ], "Version": "2012-10-17", }, "PolicyName": "DynamoDBPolicy", }, ], }, "Type": "AWS::IAM::Role", }, "simulatorMicroservicesRoleDefaultPolicy8F21950B": { "Properties": { "PolicyDocument": { "Statement": [ { "Action": "states:StartExecution", "Effect": "Allow", "Resource": { "Ref": "simulatorStepFunctionsStateMachineA2150DAB", }, }, ], "Version": "2012-10-17", }, "PolicyName": "simulatorMicroservicesRoleDefaultPolicy8F21950B", "Roles": [ { "Ref": "simulatorMicroservicesRole0AC1A17A", }, ], }, "Type": "AWS::IAM::Policy", }, "simulatorStepFunctionsExecutionAbortedAlarmC24E8F0E": { "Properties": { "AlarmDescription": "Alarm for the number of executions that aborted exceeded the threshold of 1. ", "ComparisonOperator": "GreaterThanOrEqualToThreshold", "Dimensions": [ { "Name": "StateMachineArn", "Value": { "Ref": "simulatorStepFunctionsStateMachineA2150DAB", }, }, ], "EvaluationPeriods": 1, "MetricName": "ExecutionsAborted", "Namespace": "AWS/States", "Period": 300, "Statistic": "Maximum", "Threshold": 1, }, "Type": "AWS::CloudWatch::Alarm", }, "simulatorStepFunctionsExecutionFailedAlarmACE1FB5D": { "Properties": { "AlarmDescription": "Alarm for the number of executions that failed exceeded the threshold of 1. ", "ComparisonOperator": "GreaterThanOrEqualToThreshold", "Dimensions": [ { "Name": "StateMachineArn", "Value": { "Ref": "simulatorStepFunctionsStateMachineA2150DAB", }, }, ], "EvaluationPeriods": 1, "MetricName": "ExecutionsFailed", "Namespace": "AWS/States", "Period": 300, "Statistic": "Sum", "Threshold": 1, }, "Type": "AWS::CloudWatch::Alarm", }, "simulatorStepFunctionsExecutionThrottledAlarm542D795D": { "Properties": { "AlarmDescription": "Alarm for the number of executions that throttled exceeded the threshold of 1. ", "ComparisonOperator": "GreaterThanOrEqualToThreshold", "Dimensions": [ { "Name": "StateMachineArn", "Value": { "Ref": "simulatorStepFunctionsStateMachineA2150DAB", }, }, ], "EvaluationPeriods": 1, "MetricName": "ExecutionThrottled", "Namespace": "AWS/States", "Period": 300, "Statistic": "Sum", "Threshold": 1, }, "Type": "AWS::CloudWatch::Alarm", }, "simulatorStepFunctionsLogGroupF673A0C9": { "DeletionPolicy": "Retain", "Metadata": { "cfn_nag": { "rules_to_suppress": [ { "id": "W84", "reason": "KMS encryption unnecessary for log group", }, ], }, }, "Properties": { "LogGroupName": { "Fn::Join": [ "", [ "/aws/vendedlogs/states/", { "Ref": "AWS::StackName", }, "-simulatorStepFunctionsLogGroup-testSuffix", ], ], }, "RetentionInDays": 365, }, "Type": "AWS::Logs::LogGroup", "UpdateReplacePolicy": "Retain", }, "simulatorStepFunctionsStateMachineA2150DAB": { "DeletionPolicy": "Delete", "DependsOn": [ "simulatorStepFunctionsStateMachineRoleDefaultPolicy02630DD3", "simulatorStepFunctionsStateMachineRole6FCF7FE0", ], "Metadata": { "cfn_nag": { "rules_to_suppress": [ { "id": "W11", "reason": "CloudWatch logs actions do not support resource level permissions", }, { "id": "W12", "reason": "CloudWatch logs actions do not support resource level permissions", }, ], }, }, "Properties": { "DefinitionString": { "Fn::Join": [ "", [ "{"StartAt":"getDeviceTypeMap","States":{"getDeviceTypeMap":{"Type":"Map","ResultPath":"$.simulation.devices","Next":"simulatorInvoke","Parameters":{"typeId.$":"$$.Map.Item.Value.typeId","amount.$":"$$.Map.Item.Value.amount"},"Iterator":{"StartAt":"getDeviceTypeInfo","States":{"getDeviceTypeInfo":{"End":true,"Type":"Task","ResultPath":"$.info","ResultSelector":{"name.$":"$.Item.name","topic.$":"$.Item.topic","payload.$":"$.Item.payload"},"Resource":"arn:", { "Ref": "AWS::Partition", }, ":states:::dynamodb:getItem","Parameters":{"Key":{"typeId":{"S.$":"$.typeId"}},"TableName":"", { "Ref": "TestDTypeTableEB82FCB5", }, "","ConsistentRead":false}}}},"ItemsPath":"$.simulation.devices","MaxConcurrency":0},"simulatorInvoke":{"Next":"devicesRunning?","Retry":[{"ErrorEquals":["Lambda.ServiceException","Lambda.AWSLambdaException","Lambda.SdkClientException"],"IntervalSeconds":2,"MaxAttempts":6,"BackoffRate":2}],"Catch":[{"ErrorEquals":["States.ALL"],"ResultPath":"$.error","Next":"UpdateSimTable"}],"Type":"Task","OutputPath":"$.Payload","Resource":"arn:", { "Ref": "AWS::Partition", }, ":states:::lambda:invoke","Parameters":{"FunctionName":"", { "Fn::GetAtt": [ "simulatorEngineLambda17530EFE", "Arn", ], }, "","Payload.$":"$"}},"devicesRunning?":{"Type":"Choice","Choices":[{"Variable":"$.options.restart","BooleanEquals":true,"Next":"simulatorInvoke"}],"Default":"UpdateSimTable"},"UpdateSimTable":{"Next":"Done","Catch":[{"ErrorEquals":["DynamoDB.ConditionalCheckFailedException"],"Next":"Done"}],"Type":"Task","Resource":"arn:", { "Ref": "AWS::Partition", }, ":states:::dynamodb:updateItem","Parameters":{"Key":{"simId":{"S.$":"$.simulation.simId"}},"TableName":"", { "Ref": "TestSimTable7336F78A", }, "","ConditionExpression":"attribute_exists(simId)","ExpressionAttributeValues":{":stage":{"S":"sleeping"},":time":{"S.$":"$$.State.EnteredTime"}},"UpdateExpression":"SET stage = :stage, updatedAt = :time"}},"Done":{"Type":"Succeed"}}}", ], ], }, "LoggingConfiguration": { "Destinations": [ { "CloudWatchLogsLogGroup": { "LogGroupArn": { "Fn::GetAtt": [ "simulatorStepFunctionsLogGroupF673A0C9", "Arn", ], }, }, }, ], "IncludeExecutionData": false, "Level": "ALL", }, "RoleArn": { "Fn::GetAtt": [ "simulatorStepFunctionsStateMachineRole6FCF7FE0", "Arn", ], }, }, "Type": "AWS::StepFunctions::StateMachine", "UpdateReplacePolicy": "Delete", }, "simulatorStepFunctionsStateMachineRole6FCF7FE0": { "Properties": { "AssumeRolePolicyDocument": { "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": { "Fn::FindInMap": [ "ServiceprincipalMap", { "Ref": "AWS::Region", }, "states", ], }, }, }, ], "Version": "2012-10-17", }, }, "Type": "AWS::IAM::Role", }, "simulatorStepFunctionsStateMachineRoleDefaultPolicy02630DD3": { "Metadata": { "cfn_nag": { "rules_to_suppress": [ { "id": "W12", "reason": "The 'LogDelivery' actions do not support resource-level authorizations", }, ], }, }, "Properties": { "PolicyDocument": { "Statement": [ { "Action": [ "logs:CreateLogDelivery", "logs:GetLogDelivery", "logs:UpdateLogDelivery", "logs:DeleteLogDelivery", "logs:ListLogDeliveries", ], "Effect": "Allow", "Resource": "*", }, { "Action": "lambda:InvokeFunction", "Effect": "Allow", "Resource": [ { "Fn::GetAtt": [ "simulatorEngineLambda17530EFE", "Arn", ], }, { "Fn::Join": [ "", [ { "Fn::GetAtt": [ "simulatorEngineLambda17530EFE", "Arn", ], }, ":*", ], ], }, ], }, { "Action": "dynamodb:UpdateItem", "Effect": "Allow", "Resource": { "Fn::Join": [ "", [ "arn:", { "Ref": "AWS::Partition", }, ":dynamodb:", { "Ref": "AWS::Region", }, ":", { "Ref": "AWS::AccountId", }, ":table/", { "Ref": "TestSimTable7336F78A", }, ], ], }, }, { "Action": "dynamodb:GetItem", "Effect": "Allow", "Resource": { "Fn::Join": [ "", [ "arn:", { "Ref": "AWS::Partition", }, ":dynamodb:", { "Ref": "AWS::Region", }, ":", { "Ref": "AWS::AccountId", }, ":table/", { "Ref": "TestDTypeTableEB82FCB5", }, ], ], }, }, { "Action": [ "logs:PutResourcePolicy", "logs:DescribeResourcePolicies", "logs:DescribeLogGroups", ], "Effect": "Allow", "Resource": { "Fn::Join": [ "", [ "arn:", { "Ref": "AWS::Partition", }, ":logs:", { "Ref": "AWS::Region", }, ":", { "Ref": "AWS::AccountId", }, ":*", ], ], }, }, ], "Version": "2012-10-17", }, "PolicyName": "simulatorStepFunctionsStateMachineRoleDefaultPolicy02630DD3", "Roles": [ { "Ref": "simulatorStepFunctionsStateMachineRole6FCF7FE0", }, ], }, "Type": "AWS::IAM::Policy", }, "simulatormicroservices752C24A5": { "DependsOn": [ "simulatorMicroservicesRoleDefaultPolicy8F21950B", "simulatorMicroservicesRole0AC1A17A", ], "Properties": { "Code": { "S3Bucket": "test-bucket-region", "S3Key": "testPrefix//microservices.zip", }, "Description": "IoT Device Simulator microservices function", "Environment": { "Variables": { "DEVICE_TYPES_TBL": { "Ref": "TestDTypeTableEB82FCB5", }, "SEND_ANONYMOUS_METRIC": "Yes", "SIMULATIONS_TBL": { "Ref": "TestSimTable7336F78A", }, "SIM_STEP_FUNCTION": { "Ref": "simulatorStepFunctionsStateMachineA2150DAB", }, "SOLUTION_ID": "testId", "UUID": "abc123", "VERSION": "testVersion", }, }, "Handler": "index.handler", "Role": { "Fn::GetAtt": [ "simulatorMicroservicesRole0AC1A17A", "Arn", ], }, "Runtime": "nodejs18.x", "Timeout": 60, }, "Type": "AWS::Lambda::Function", }, "testRouteBucket64D9BEB5": { "DeletionPolicy": "Retain", "Type": "AWS::S3::Bucket", "UpdateReplacePolicy": "Retain", }, }, } `;