{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "An auto-generated nested stack.",
    "Metadata": {},
    "Parameters": {
        "AppSyncApiName": {
            "Type": "String",
            "Description": "The name of the AppSync API",
            "Default": "AppSyncSimpleTransform"
        },
        "APIKeyExpirationEpoch": {
            "Type": "Number",
            "Description": "The epoch time in seconds when the API Key should expire. Setting this to 0 will default to 1 week from the deployment date. Setting this to -1 will not create an API Key.",
            "Default": 0
        },
        "DynamoDBModelTableReadIOPS": {
            "Type": "Number",
            "Description": "The number of read IOPS the table should support.",
            "Default": 5
        },
        "DynamoDBModelTableWriteIOPS": {
            "Type": "Number",
            "Description": "The number of write IOPS the table should support.",
            "Default": 5
        },
        "DynamoDBBillingMode": {
            "Type": "String",
            "Description": "Configure @model types to create DynamoDB tables with PAY_PER_REQUEST or PROVISIONED billing modes.",
            "Default": "PAY_PER_REQUEST",
            "AllowedValues": [
                "PAY_PER_REQUEST",
                "PROVISIONED"
            ]
        },
        "DynamoDBEnablePointInTimeRecovery": {
            "Type": "String",
            "Description": "Whether to enable Point in Time Recovery on the table",
            "Default": "false",
            "AllowedValues": [
                "true",
                "false"
            ]
        },
        "AuthCognitoUserPoolId": {
            "Type": "String",
            "Description": "The id of an existing User Pool to connect. If this is changed, a user pool will not be created for you.",
            "Default": "NONE"
        },
        "env": {
            "Type": "String",
            "Description": "The environment name. e.g. Dev, Test, or Production",
            "Default": "NONE"
        },
        "S3DeploymentBucket": {
            "Type": "String",
            "Description": "The S3 bucket containing all deployment assets for the project."
        },
        "S3DeploymentRootKey": {
            "Type": "String",
            "Description": "An S3 key relative to the S3DeploymentBucket that points to the root of the deployment directory."
        }
    },
    "Resources": {
        "GraphQLAPI": {
            "Type": "AWS::AppSync::GraphQLApi",
            "Properties": {
                "Name": {
                    "Fn::If": [
                        "HasEnvironmentParameter",
                        {
                            "Fn::Join": [
                                "-",
                                [
                                    {
                                        "Ref": "AppSyncApiName"
                                    },
                                    {
                                        "Ref": "env"
                                    }
                                ]
                            ]
                        },
                        {
                            "Ref": "AppSyncApiName"
                        }
                    ]
                },
                "AuthenticationType": "AMAZON_COGNITO_USER_POOLS",
                "UserPoolConfig": {
                    "UserPoolId": {
                        "Ref": "AuthCognitoUserPoolId"
                    },
                    "AwsRegion": {
                        "Ref": "AWS::Region"
                    },
                    "DefaultAction": "ALLOW"
                }
            }
        },
        "HomeTable": {
            "Type": "AWS::DynamoDB::Table",
            "Properties": {
                "TableName": {
                    "Fn::If": [
                        "HasEnvironmentParameter",
                        {
                            "Fn::Join": [
                                "-",
                                [
                                    "Home",
                                    {
                                        "Fn::GetAtt": [
                                            "GraphQLAPI",
                                            "ApiId"
                                        ]
                                    },
                                    {
                                        "Ref": "env"
                                    }
                                ]
                            ]
                        },
                        {
                            "Fn::Join": [
                                "-",
                                [
                                    "Home",
                                    {
                                        "Fn::GetAtt": [
                                            "GraphQLAPI",
                                            "ApiId"
                                        ]
                                    }
                                ]
                            ]
                        }
                    ]
                },
                "KeySchema": [
                    {
                        "AttributeName": "id",
                        "KeyType": "HASH"
                    }
                ],
                "AttributeDefinitions": [
                    {
                        "AttributeName": "id",
                        "AttributeType": "S"
                    }
                ],
                "StreamSpecification": {
                    "StreamViewType": "NEW_AND_OLD_IMAGES"
                },
                "BillingMode": {
                    "Fn::If": [
                        "ShouldUsePayPerRequestBilling",
                        "PAY_PER_REQUEST",
                        {
                            "Ref": "AWS::NoValue"
                        }
                    ]
                },
                "ProvisionedThroughput": {
                    "Fn::If": [
                        "ShouldUsePayPerRequestBilling",
                        {
                            "Ref": "AWS::NoValue"
                        },
                        {
                            "ReadCapacityUnits": {
                                "Ref": "DynamoDBModelTableReadIOPS"
                            },
                            "WriteCapacityUnits": {
                                "Ref": "DynamoDBModelTableWriteIOPS"
                            }
                        }
                    ]
                },
                "PointInTimeRecoverySpecification": {
                    "Fn::If": [
                        "ShouldUsePointInTimeRecovery",
                        {
                            "PointInTimeRecoveryEnabled": true
                        },
                        {
                            "Ref": "AWS::NoValue"
                        }
                    ]
                }
            }
        },
        "RoomTable": {
            "Type": "AWS::DynamoDB::Table",
            "Properties": {
                "TableName": {
                    "Fn::If": [
                        "HasEnvironmentParameter",
                        {
                            "Fn::Join": [
                                "-",
                                [
                                    "Room",
                                    {
                                        "Fn::GetAtt": [
                                            "GraphQLAPI",
                                            "ApiId"
                                        ]
                                    },
                                    {
                                        "Ref": "env"
                                    }
                                ]
                            ]
                        },
                        {
                            "Fn::Join": [
                                "-",
                                [
                                    "Room",
                                    {
                                        "Fn::GetAtt": [
                                            "GraphQLAPI",
                                            "ApiId"
                                        ]
                                    }
                                ]
                            ]
                        }
                    ]
                },
                "KeySchema": [
                    {
                        "AttributeName": "id",
                        "KeyType": "HASH"
                    }
                ],
                "AttributeDefinitions": [
                    {
                        "AttributeName": "id",
                        "AttributeType": "S"
                    },
                    {
                        "AttributeName": "roomHomeId",
                        "AttributeType": "S"
                    }
                ],
                "StreamSpecification": {
                    "StreamViewType": "NEW_AND_OLD_IMAGES"
                },
                "BillingMode": {
                    "Fn::If": [
                        "ShouldUsePayPerRequestBilling",
                        "PAY_PER_REQUEST",
                        {
                            "Ref": "AWS::NoValue"
                        }
                    ]
                },
                "ProvisionedThroughput": {
                    "Fn::If": [
                        "ShouldUsePayPerRequestBilling",
                        {
                            "Ref": "AWS::NoValue"
                        },
                        {
                            "ReadCapacityUnits": {
                                "Ref": "DynamoDBModelTableReadIOPS"
                            },
                            "WriteCapacityUnits": {
                                "Ref": "DynamoDBModelTableWriteIOPS"
                            }
                        }
                    ]
                },
                "PointInTimeRecoverySpecification": {
                    "Fn::If": [
                        "ShouldUsePointInTimeRecovery",
                        {
                            "PointInTimeRecoveryEnabled": true
                        },
                        {
                            "Ref": "AWS::NoValue"
                        }
                    ]
                },
                "GlobalSecondaryIndexes": [
                    {
                        "IndexName": "gsi-HomeRooms",
                        "KeySchema": [
                            {
                                "AttributeName": "roomHomeId",
                                "KeyType": "HASH"
                            }
                        ],
                        "Projection": {
                            "ProjectionType": "ALL"
                        },
                        "ProvisionedThroughput": {
                            "Fn::If": [
                                "ShouldUsePayPerRequestBilling",
                                {
                                    "Ref": "AWS::NoValue"
                                },
                                {
                                    "ReadCapacityUnits": {
                                        "Ref": "DynamoDBModelTableReadIOPS"
                                    },
                                    "WriteCapacityUnits": {
                                        "Ref": "DynamoDBModelTableWriteIOPS"
                                    }
                                }
                            ]
                        }
                    }
                ]
            }
        },
        "ShadeTable": {
            "Type": "AWS::DynamoDB::Table",
            "Properties": {
                "TableName": {
                    "Fn::If": [
                        "HasEnvironmentParameter",
                        {
                            "Fn::Join": [
                                "-",
                                [
                                    "Shade",
                                    {
                                        "Fn::GetAtt": [
                                            "GraphQLAPI",
                                            "ApiId"
                                        ]
                                    },
                                    {
                                        "Ref": "env"
                                    }
                                ]
                            ]
                        },
                        {
                            "Fn::Join": [
                                "-",
                                [
                                    "Shade",
                                    {
                                        "Fn::GetAtt": [
                                            "GraphQLAPI",
                                            "ApiId"
                                        ]
                                    }
                                ]
                            ]
                        }
                    ]
                },
                "KeySchema": [
                    {
                        "AttributeName": "id",
                        "KeyType": "HASH"
                    }
                ],
                "AttributeDefinitions": [
                    {
                        "AttributeName": "id",
                        "AttributeType": "S"
                    },
                    {
                        "AttributeName": "shadeHomeId",
                        "AttributeType": "S"
                    },
                    {
                        "AttributeName": "shadeRoomId",
                        "AttributeType": "S"
                    }
                ],
                "StreamSpecification": {
                    "StreamViewType": "NEW_AND_OLD_IMAGES"
                },
                "BillingMode": {
                    "Fn::If": [
                        "ShouldUsePayPerRequestBilling",
                        "PAY_PER_REQUEST",
                        {
                            "Ref": "AWS::NoValue"
                        }
                    ]
                },
                "ProvisionedThroughput": {
                    "Fn::If": [
                        "ShouldUsePayPerRequestBilling",
                        {
                            "Ref": "AWS::NoValue"
                        },
                        {
                            "ReadCapacityUnits": {
                                "Ref": "DynamoDBModelTableReadIOPS"
                            },
                            "WriteCapacityUnits": {
                                "Ref": "DynamoDBModelTableWriteIOPS"
                            }
                        }
                    ]
                },
                "PointInTimeRecoverySpecification": {
                    "Fn::If": [
                        "ShouldUsePointInTimeRecovery",
                        {
                            "PointInTimeRecoveryEnabled": true
                        },
                        {
                            "Ref": "AWS::NoValue"
                        }
                    ]
                },
                "GlobalSecondaryIndexes": [
                    {
                        "IndexName": "gsi-HomeShades",
                        "KeySchema": [
                            {
                                "AttributeName": "shadeHomeId",
                                "KeyType": "HASH"
                            }
                        ],
                        "Projection": {
                            "ProjectionType": "ALL"
                        },
                        "ProvisionedThroughput": {
                            "Fn::If": [
                                "ShouldUsePayPerRequestBilling",
                                {
                                    "Ref": "AWS::NoValue"
                                },
                                {
                                    "ReadCapacityUnits": {
                                        "Ref": "DynamoDBModelTableReadIOPS"
                                    },
                                    "WriteCapacityUnits": {
                                        "Ref": "DynamoDBModelTableWriteIOPS"
                                    }
                                }
                            ]
                        }
                    },
                    {
                        "IndexName": "gsi-RoomShades",
                        "KeySchema": [
                            {
                                "AttributeName": "shadeRoomId",
                                "KeyType": "HASH"
                            }
                        ],
                        "Projection": {
                            "ProjectionType": "ALL"
                        },
                        "ProvisionedThroughput": {
                            "Fn::If": [
                                "ShouldUsePayPerRequestBilling",
                                {
                                    "Ref": "AWS::NoValue"
                                },
                                {
                                    "ReadCapacityUnits": {
                                        "Ref": "DynamoDBModelTableReadIOPS"
                                    },
                                    "WriteCapacityUnits": {
                                        "Ref": "DynamoDBModelTableWriteIOPS"
                                    }
                                }
                            ]
                        }
                    }
                ]
            }
        },
        "SceneTable": {
            "Type": "AWS::DynamoDB::Table",
            "Properties": {
                "TableName": {
                    "Fn::If": [
                        "HasEnvironmentParameter",
                        {
                            "Fn::Join": [
                                "-",
                                [
                                    "Scene",
                                    {
                                        "Fn::GetAtt": [
                                            "GraphQLAPI",
                                            "ApiId"
                                        ]
                                    },
                                    {
                                        "Ref": "env"
                                    }
                                ]
                            ]
                        },
                        {
                            "Fn::Join": [
                                "-",
                                [
                                    "Scene",
                                    {
                                        "Fn::GetAtt": [
                                            "GraphQLAPI",
                                            "ApiId"
                                        ]
                                    }
                                ]
                            ]
                        }
                    ]
                },
                "KeySchema": [
                    {
                        "AttributeName": "id",
                        "KeyType": "HASH"
                    }
                ],
                "AttributeDefinitions": [
                    {
                        "AttributeName": "id",
                        "AttributeType": "S"
                    },
                    {
                        "AttributeName": "sceneHomeId",
                        "AttributeType": "S"
                    }
                ],
                "StreamSpecification": {
                    "StreamViewType": "NEW_AND_OLD_IMAGES"
                },
                "BillingMode": {
                    "Fn::If": [
                        "ShouldUsePayPerRequestBilling",
                        "PAY_PER_REQUEST",
                        {
                            "Ref": "AWS::NoValue"
                        }
                    ]
                },
                "ProvisionedThroughput": {
                    "Fn::If": [
                        "ShouldUsePayPerRequestBilling",
                        {
                            "Ref": "AWS::NoValue"
                        },
                        {
                            "ReadCapacityUnits": {
                                "Ref": "DynamoDBModelTableReadIOPS"
                            },
                            "WriteCapacityUnits": {
                                "Ref": "DynamoDBModelTableWriteIOPS"
                            }
                        }
                    ]
                },
                "PointInTimeRecoverySpecification": {
                    "Fn::If": [
                        "ShouldUsePointInTimeRecovery",
                        {
                            "PointInTimeRecoveryEnabled": true
                        },
                        {
                            "Ref": "AWS::NoValue"
                        }
                    ]
                },
                "GlobalSecondaryIndexes": [
                    {
                        "IndexName": "gsi-HomeScenes",
                        "KeySchema": [
                            {
                                "AttributeName": "sceneHomeId",
                                "KeyType": "HASH"
                            }
                        ],
                        "Projection": {
                            "ProjectionType": "ALL"
                        },
                        "ProvisionedThroughput": {
                            "Fn::If": [
                                "ShouldUsePayPerRequestBilling",
                                {
                                    "Ref": "AWS::NoValue"
                                },
                                {
                                    "ReadCapacityUnits": {
                                        "Ref": "DynamoDBModelTableReadIOPS"
                                    },
                                    "WriteCapacityUnits": {
                                        "Ref": "DynamoDBModelTableWriteIOPS"
                                    }
                                }
                            ]
                        }
                    }
                ]
            }
        },
        "AutomationTable": {
            "Type": "AWS::DynamoDB::Table",
            "Properties": {
                "TableName": {
                    "Fn::If": [
                        "HasEnvironmentParameter",
                        {
                            "Fn::Join": [
                                "-",
                                [
                                    "Automation",
                                    {
                                        "Fn::GetAtt": [
                                            "GraphQLAPI",
                                            "ApiId"
                                        ]
                                    },
                                    {
                                        "Ref": "env"
                                    }
                                ]
                            ]
                        },
                        {
                            "Fn::Join": [
                                "-",
                                [
                                    "Automation",
                                    {
                                        "Fn::GetAtt": [
                                            "GraphQLAPI",
                                            "ApiId"
                                        ]
                                    }
                                ]
                            ]
                        }
                    ]
                },
                "KeySchema": [
                    {
                        "AttributeName": "id",
                        "KeyType": "HASH"
                    }
                ],
                "AttributeDefinitions": [
                    {
                        "AttributeName": "id",
                        "AttributeType": "S"
                    },
                    {
                        "AttributeName": "automationHomeId",
                        "AttributeType": "S"
                    },
                    {
                        "AttributeName": "automationSceneId",
                        "AttributeType": "S"
                    }
                ],
                "StreamSpecification": {
                    "StreamViewType": "NEW_AND_OLD_IMAGES"
                },
                "BillingMode": {
                    "Fn::If": [
                        "ShouldUsePayPerRequestBilling",
                        "PAY_PER_REQUEST",
                        {
                            "Ref": "AWS::NoValue"
                        }
                    ]
                },
                "ProvisionedThroughput": {
                    "Fn::If": [
                        "ShouldUsePayPerRequestBilling",
                        {
                            "Ref": "AWS::NoValue"
                        },
                        {
                            "ReadCapacityUnits": {
                                "Ref": "DynamoDBModelTableReadIOPS"
                            },
                            "WriteCapacityUnits": {
                                "Ref": "DynamoDBModelTableWriteIOPS"
                            }
                        }
                    ]
                },
                "PointInTimeRecoverySpecification": {
                    "Fn::If": [
                        "ShouldUsePointInTimeRecovery",
                        {
                            "PointInTimeRecoveryEnabled": true
                        },
                        {
                            "Ref": "AWS::NoValue"
                        }
                    ]
                },
                "GlobalSecondaryIndexes": [
                    {
                        "IndexName": "gsi-HomeAutomations",
                        "KeySchema": [
                            {
                                "AttributeName": "automationHomeId",
                                "KeyType": "HASH"
                            }
                        ],
                        "Projection": {
                            "ProjectionType": "ALL"
                        },
                        "ProvisionedThroughput": {
                            "Fn::If": [
                                "ShouldUsePayPerRequestBilling",
                                {
                                    "Ref": "AWS::NoValue"
                                },
                                {
                                    "ReadCapacityUnits": {
                                        "Ref": "DynamoDBModelTableReadIOPS"
                                    },
                                    "WriteCapacityUnits": {
                                        "Ref": "DynamoDBModelTableWriteIOPS"
                                    }
                                }
                            ]
                        }
                    },
                    {
                        "IndexName": "gsi-AutomationScene",
                        "KeySchema": [
                            {
                                "AttributeName": "automationSceneId",
                                "KeyType": "HASH"
                            }
                        ],
                        "Projection": {
                            "ProjectionType": "ALL"
                        },
                        "ProvisionedThroughput": {
                            "Fn::If": [
                                "ShouldUsePayPerRequestBilling",
                                {
                                    "Ref": "AWS::NoValue"
                                },
                                {
                                    "ReadCapacityUnits": {
                                        "Ref": "DynamoDBModelTableReadIOPS"
                                    },
                                    "WriteCapacityUnits": {
                                        "Ref": "DynamoDBModelTableWriteIOPS"
                                    }
                                }
                            ]
                        }
                    }
                ]
            }
        },
        "GraphQLAPIKey": {
            "Type": "AWS::AppSync::ApiKey",
            "Properties": {
                "ApiId": {
                    "Fn::GetAtt": [
                        "GraphQLAPI",
                        "ApiId"
                    ]
                },
                "Expires": {
                    "Fn::If": [
                        "APIKeyExpirationEpochIsPositive",
                        {
                            "Ref": "APIKeyExpirationEpoch"
                        },
                        1560975870
                    ]
                }
            },
            "Condition": "ShouldCreateAPIKey"
        },
        "GraphQLSchema": {
            "Type": "AWS::AppSync::GraphQLSchema",
            "Properties": {
                "ApiId": {
                    "Fn::GetAtt": [
                        "GraphQLAPI",
                        "ApiId"
                    ]
                },
                "DefinitionS3Location": {
                    "Fn::Sub": [
                        "s3://${S3DeploymentBucket}/${S3DeploymentRootKey}/schema.graphql",
                        {
                            "S3DeploymentBucket": {
                                "Ref": "S3DeploymentBucket"
                            },
                            "S3DeploymentRootKey": {
                                "Ref": "S3DeploymentRootKey"
                            }
                        }
                    ]
                }
            }
        },
        "Home": {
            "Type": "AWS::CloudFormation::Stack",
            "Properties": {
                "Parameters": {
                    "AppSyncApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    },
                    "AppSyncApiName": {
                        "Ref": "AppSyncApiName"
                    },
                    "APIKeyExpirationEpoch": {
                        "Ref": "APIKeyExpirationEpoch"
                    },
                    "DynamoDBModelTableReadIOPS": {
                        "Ref": "DynamoDBModelTableReadIOPS"
                    },
                    "DynamoDBModelTableWriteIOPS": {
                        "Ref": "DynamoDBModelTableWriteIOPS"
                    },
                    "DynamoDBBillingMode": {
                        "Ref": "DynamoDBBillingMode"
                    },
                    "DynamoDBEnablePointInTimeRecovery": {
                        "Ref": "DynamoDBEnablePointInTimeRecovery"
                    },
                    "AuthCognitoUserPoolId": {
                        "Ref": "AuthCognitoUserPoolId"
                    },
                    "env": {
                        "Ref": "env"
                    },
                    "S3DeploymentBucket": {
                        "Ref": "S3DeploymentBucket"
                    },
                    "S3DeploymentRootKey": {
                        "Ref": "S3DeploymentRootKey"
                    },
                    "GetAttGraphQLAPIApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    }
                },
                "TemplateURL": {
                    "Fn::Join": [
                        "/",
                        [
                            "https://s3.amazonaws.com",
                            {
                                "Ref": "S3DeploymentBucket"
                            },
                            {
                                "Ref": "S3DeploymentRootKey"
                            },
                            "stacks",
                            "Home.json"
                        ]
                    ]
                }
            },
            "DependsOn": [
                "GraphQLSchema"
            ]
        },
        "Gateway": {
            "Type": "AWS::CloudFormation::Stack",
            "Properties": {
                "Parameters": {
                    "AppSyncApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    },
                    "AppSyncApiName": {
                        "Ref": "AppSyncApiName"
                    },
                    "APIKeyExpirationEpoch": {
                        "Ref": "APIKeyExpirationEpoch"
                    },
                    "DynamoDBModelTableReadIOPS": {
                        "Ref": "DynamoDBModelTableReadIOPS"
                    },
                    "DynamoDBModelTableWriteIOPS": {
                        "Ref": "DynamoDBModelTableWriteIOPS"
                    },
                    "DynamoDBBillingMode": {
                        "Ref": "DynamoDBBillingMode"
                    },
                    "DynamoDBEnablePointInTimeRecovery": {
                        "Ref": "DynamoDBEnablePointInTimeRecovery"
                    },
                    "AuthCognitoUserPoolId": {
                        "Ref": "AuthCognitoUserPoolId"
                    },
                    "env": {
                        "Ref": "env"
                    },
                    "S3DeploymentBucket": {
                        "Ref": "S3DeploymentBucket"
                    },
                    "S3DeploymentRootKey": {
                        "Ref": "S3DeploymentRootKey"
                    },
                    "GetAttGraphQLAPIApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    }
                },
                "TemplateURL": {
                    "Fn::Join": [
                        "/",
                        [
                            "https://s3.amazonaws.com",
                            {
                                "Ref": "S3DeploymentBucket"
                            },
                            {
                                "Ref": "S3DeploymentRootKey"
                            },
                            "stacks",
                            "Gateway.json"
                        ]
                    ]
                }
            },
            "DependsOn": [
                "GraphQLSchema"
            ]
        },
        "Room": {
            "Type": "AWS::CloudFormation::Stack",
            "Properties": {
                "Parameters": {
                    "AppSyncApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    },
                    "AppSyncApiName": {
                        "Ref": "AppSyncApiName"
                    },
                    "APIKeyExpirationEpoch": {
                        "Ref": "APIKeyExpirationEpoch"
                    },
                    "DynamoDBModelTableReadIOPS": {
                        "Ref": "DynamoDBModelTableReadIOPS"
                    },
                    "DynamoDBModelTableWriteIOPS": {
                        "Ref": "DynamoDBModelTableWriteIOPS"
                    },
                    "DynamoDBBillingMode": {
                        "Ref": "DynamoDBBillingMode"
                    },
                    "DynamoDBEnablePointInTimeRecovery": {
                        "Ref": "DynamoDBEnablePointInTimeRecovery"
                    },
                    "AuthCognitoUserPoolId": {
                        "Ref": "AuthCognitoUserPoolId"
                    },
                    "env": {
                        "Ref": "env"
                    },
                    "S3DeploymentBucket": {
                        "Ref": "S3DeploymentBucket"
                    },
                    "S3DeploymentRootKey": {
                        "Ref": "S3DeploymentRootKey"
                    },
                    "GetAttGraphQLAPIApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    }
                },
                "TemplateURL": {
                    "Fn::Join": [
                        "/",
                        [
                            "https://s3.amazonaws.com",
                            {
                                "Ref": "S3DeploymentBucket"
                            },
                            {
                                "Ref": "S3DeploymentRootKey"
                            },
                            "stacks",
                            "Room.json"
                        ]
                    ]
                }
            },
            "DependsOn": [
                "GraphQLSchema"
            ]
        },
        "Shade": {
            "Type": "AWS::CloudFormation::Stack",
            "Properties": {
                "Parameters": {
                    "AppSyncApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    },
                    "AppSyncApiName": {
                        "Ref": "AppSyncApiName"
                    },
                    "APIKeyExpirationEpoch": {
                        "Ref": "APIKeyExpirationEpoch"
                    },
                    "DynamoDBModelTableReadIOPS": {
                        "Ref": "DynamoDBModelTableReadIOPS"
                    },
                    "DynamoDBModelTableWriteIOPS": {
                        "Ref": "DynamoDBModelTableWriteIOPS"
                    },
                    "DynamoDBBillingMode": {
                        "Ref": "DynamoDBBillingMode"
                    },
                    "DynamoDBEnablePointInTimeRecovery": {
                        "Ref": "DynamoDBEnablePointInTimeRecovery"
                    },
                    "AuthCognitoUserPoolId": {
                        "Ref": "AuthCognitoUserPoolId"
                    },
                    "env": {
                        "Ref": "env"
                    },
                    "S3DeploymentBucket": {
                        "Ref": "S3DeploymentBucket"
                    },
                    "S3DeploymentRootKey": {
                        "Ref": "S3DeploymentRootKey"
                    },
                    "GetAttGraphQLAPIApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    }
                },
                "TemplateURL": {
                    "Fn::Join": [
                        "/",
                        [
                            "https://s3.amazonaws.com",
                            {
                                "Ref": "S3DeploymentBucket"
                            },
                            {
                                "Ref": "S3DeploymentRootKey"
                            },
                            "stacks",
                            "Shade.json"
                        ]
                    ]
                }
            },
            "DependsOn": [
                "GraphQLSchema"
            ]
        },
        "Scene": {
            "Type": "AWS::CloudFormation::Stack",
            "Properties": {
                "Parameters": {
                    "AppSyncApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    },
                    "AppSyncApiName": {
                        "Ref": "AppSyncApiName"
                    },
                    "APIKeyExpirationEpoch": {
                        "Ref": "APIKeyExpirationEpoch"
                    },
                    "DynamoDBModelTableReadIOPS": {
                        "Ref": "DynamoDBModelTableReadIOPS"
                    },
                    "DynamoDBModelTableWriteIOPS": {
                        "Ref": "DynamoDBModelTableWriteIOPS"
                    },
                    "DynamoDBBillingMode": {
                        "Ref": "DynamoDBBillingMode"
                    },
                    "DynamoDBEnablePointInTimeRecovery": {
                        "Ref": "DynamoDBEnablePointInTimeRecovery"
                    },
                    "AuthCognitoUserPoolId": {
                        "Ref": "AuthCognitoUserPoolId"
                    },
                    "env": {
                        "Ref": "env"
                    },
                    "S3DeploymentBucket": {
                        "Ref": "S3DeploymentBucket"
                    },
                    "S3DeploymentRootKey": {
                        "Ref": "S3DeploymentRootKey"
                    },
                    "GetAttGraphQLAPIApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    }
                },
                "TemplateURL": {
                    "Fn::Join": [
                        "/",
                        [
                            "https://s3.amazonaws.com",
                            {
                                "Ref": "S3DeploymentBucket"
                            },
                            {
                                "Ref": "S3DeploymentRootKey"
                            },
                            "stacks",
                            "Scene.json"
                        ]
                    ]
                }
            },
            "DependsOn": [
                "GraphQLSchema"
            ]
        },
        "SceneAction": {
            "Type": "AWS::CloudFormation::Stack",
            "Properties": {
                "Parameters": {
                    "AppSyncApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    },
                    "AppSyncApiName": {
                        "Ref": "AppSyncApiName"
                    },
                    "APIKeyExpirationEpoch": {
                        "Ref": "APIKeyExpirationEpoch"
                    },
                    "DynamoDBModelTableReadIOPS": {
                        "Ref": "DynamoDBModelTableReadIOPS"
                    },
                    "DynamoDBModelTableWriteIOPS": {
                        "Ref": "DynamoDBModelTableWriteIOPS"
                    },
                    "DynamoDBBillingMode": {
                        "Ref": "DynamoDBBillingMode"
                    },
                    "DynamoDBEnablePointInTimeRecovery": {
                        "Ref": "DynamoDBEnablePointInTimeRecovery"
                    },
                    "AuthCognitoUserPoolId": {
                        "Ref": "AuthCognitoUserPoolId"
                    },
                    "env": {
                        "Ref": "env"
                    },
                    "S3DeploymentBucket": {
                        "Ref": "S3DeploymentBucket"
                    },
                    "S3DeploymentRootKey": {
                        "Ref": "S3DeploymentRootKey"
                    },
                    "GetAttGraphQLAPIApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    }
                },
                "TemplateURL": {
                    "Fn::Join": [
                        "/",
                        [
                            "https://s3.amazonaws.com",
                            {
                                "Ref": "S3DeploymentBucket"
                            },
                            {
                                "Ref": "S3DeploymentRootKey"
                            },
                            "stacks",
                            "SceneAction.json"
                        ]
                    ]
                }
            },
            "DependsOn": [
                "GraphQLSchema"
            ]
        },
        "Automation": {
            "Type": "AWS::CloudFormation::Stack",
            "Properties": {
                "Parameters": {
                    "AppSyncApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    },
                    "AppSyncApiName": {
                        "Ref": "AppSyncApiName"
                    },
                    "APIKeyExpirationEpoch": {
                        "Ref": "APIKeyExpirationEpoch"
                    },
                    "DynamoDBModelTableReadIOPS": {
                        "Ref": "DynamoDBModelTableReadIOPS"
                    },
                    "DynamoDBModelTableWriteIOPS": {
                        "Ref": "DynamoDBModelTableWriteIOPS"
                    },
                    "DynamoDBBillingMode": {
                        "Ref": "DynamoDBBillingMode"
                    },
                    "DynamoDBEnablePointInTimeRecovery": {
                        "Ref": "DynamoDBEnablePointInTimeRecovery"
                    },
                    "AuthCognitoUserPoolId": {
                        "Ref": "AuthCognitoUserPoolId"
                    },
                    "env": {
                        "Ref": "env"
                    },
                    "S3DeploymentBucket": {
                        "Ref": "S3DeploymentBucket"
                    },
                    "S3DeploymentRootKey": {
                        "Ref": "S3DeploymentRootKey"
                    },
                    "GetAttGraphQLAPIApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    }
                },
                "TemplateURL": {
                    "Fn::Join": [
                        "/",
                        [
                            "https://s3.amazonaws.com",
                            {
                                "Ref": "S3DeploymentBucket"
                            },
                            {
                                "Ref": "S3DeploymentRootKey"
                            },
                            "stacks",
                            "Automation.json"
                        ]
                    ]
                }
            },
            "DependsOn": [
                "GraphQLSchema"
            ]
        },
        "Remote": {
            "Type": "AWS::CloudFormation::Stack",
            "Properties": {
                "Parameters": {
                    "AppSyncApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    },
                    "AppSyncApiName": {
                        "Ref": "AppSyncApiName"
                    },
                    "APIKeyExpirationEpoch": {
                        "Ref": "APIKeyExpirationEpoch"
                    },
                    "DynamoDBModelTableReadIOPS": {
                        "Ref": "DynamoDBModelTableReadIOPS"
                    },
                    "DynamoDBModelTableWriteIOPS": {
                        "Ref": "DynamoDBModelTableWriteIOPS"
                    },
                    "DynamoDBBillingMode": {
                        "Ref": "DynamoDBBillingMode"
                    },
                    "DynamoDBEnablePointInTimeRecovery": {
                        "Ref": "DynamoDBEnablePointInTimeRecovery"
                    },
                    "AuthCognitoUserPoolId": {
                        "Ref": "AuthCognitoUserPoolId"
                    },
                    "env": {
                        "Ref": "env"
                    },
                    "S3DeploymentBucket": {
                        "Ref": "S3DeploymentBucket"
                    },
                    "S3DeploymentRootKey": {
                        "Ref": "S3DeploymentRootKey"
                    },
                    "GetAttGraphQLAPIApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    }
                },
                "TemplateURL": {
                    "Fn::Join": [
                        "/",
                        [
                            "https://s3.amazonaws.com",
                            {
                                "Ref": "S3DeploymentBucket"
                            },
                            {
                                "Ref": "S3DeploymentRootKey"
                            },
                            "stacks",
                            "Remote.json"
                        ]
                    ]
                }
            },
            "DependsOn": [
                "GraphQLSchema"
            ]
        },
        "RemoteGroup": {
            "Type": "AWS::CloudFormation::Stack",
            "Properties": {
                "Parameters": {
                    "AppSyncApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    },
                    "AppSyncApiName": {
                        "Ref": "AppSyncApiName"
                    },
                    "APIKeyExpirationEpoch": {
                        "Ref": "APIKeyExpirationEpoch"
                    },
                    "DynamoDBModelTableReadIOPS": {
                        "Ref": "DynamoDBModelTableReadIOPS"
                    },
                    "DynamoDBModelTableWriteIOPS": {
                        "Ref": "DynamoDBModelTableWriteIOPS"
                    },
                    "DynamoDBBillingMode": {
                        "Ref": "DynamoDBBillingMode"
                    },
                    "DynamoDBEnablePointInTimeRecovery": {
                        "Ref": "DynamoDBEnablePointInTimeRecovery"
                    },
                    "AuthCognitoUserPoolId": {
                        "Ref": "AuthCognitoUserPoolId"
                    },
                    "env": {
                        "Ref": "env"
                    },
                    "S3DeploymentBucket": {
                        "Ref": "S3DeploymentBucket"
                    },
                    "S3DeploymentRootKey": {
                        "Ref": "S3DeploymentRootKey"
                    },
                    "GetAttGraphQLAPIApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    }
                },
                "TemplateURL": {
                    "Fn::Join": [
                        "/",
                        [
                            "https://s3.amazonaws.com",
                            {
                                "Ref": "S3DeploymentBucket"
                            },
                            {
                                "Ref": "S3DeploymentRootKey"
                            },
                            "stacks",
                            "RemoteGroup.json"
                        ]
                    ]
                }
            },
            "DependsOn": [
                "GraphQLSchema"
            ]
        },
        "GatewayCommand": {
            "Type": "AWS::CloudFormation::Stack",
            "Properties": {
                "Parameters": {
                    "AppSyncApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    },
                    "AppSyncApiName": {
                        "Ref": "AppSyncApiName"
                    },
                    "APIKeyExpirationEpoch": {
                        "Ref": "APIKeyExpirationEpoch"
                    },
                    "DynamoDBModelTableReadIOPS": {
                        "Ref": "DynamoDBModelTableReadIOPS"
                    },
                    "DynamoDBModelTableWriteIOPS": {
                        "Ref": "DynamoDBModelTableWriteIOPS"
                    },
                    "DynamoDBBillingMode": {
                        "Ref": "DynamoDBBillingMode"
                    },
                    "DynamoDBEnablePointInTimeRecovery": {
                        "Ref": "DynamoDBEnablePointInTimeRecovery"
                    },
                    "AuthCognitoUserPoolId": {
                        "Ref": "AuthCognitoUserPoolId"
                    },
                    "env": {
                        "Ref": "env"
                    },
                    "S3DeploymentBucket": {
                        "Ref": "S3DeploymentBucket"
                    },
                    "S3DeploymentRootKey": {
                        "Ref": "S3DeploymentRootKey"
                    },
                    "GetAttGraphQLAPIApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    }
                },
                "TemplateURL": {
                    "Fn::Join": [
                        "/",
                        [
                            "https://s3.amazonaws.com",
                            {
                                "Ref": "S3DeploymentBucket"
                            },
                            {
                                "Ref": "S3DeploymentRootKey"
                            },
                            "stacks",
                            "GatewayCommand.json"
                        ]
                    ]
                }
            },
            "DependsOn": [
                "GraphQLSchema"
            ]
        },
        "ConnectionStack": {
            "Type": "AWS::CloudFormation::Stack",
            "Properties": {
                "Parameters": {
                    "AppSyncApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    },
                    "AppSyncApiName": {
                        "Ref": "AppSyncApiName"
                    },
                    "APIKeyExpirationEpoch": {
                        "Ref": "APIKeyExpirationEpoch"
                    },
                    "DynamoDBModelTableReadIOPS": {
                        "Ref": "DynamoDBModelTableReadIOPS"
                    },
                    "DynamoDBModelTableWriteIOPS": {
                        "Ref": "DynamoDBModelTableWriteIOPS"
                    },
                    "DynamoDBBillingMode": {
                        "Ref": "DynamoDBBillingMode"
                    },
                    "DynamoDBEnablePointInTimeRecovery": {
                        "Ref": "DynamoDBEnablePointInTimeRecovery"
                    },
                    "AuthCognitoUserPoolId": {
                        "Ref": "AuthCognitoUserPoolId"
                    },
                    "env": {
                        "Ref": "env"
                    },
                    "S3DeploymentBucket": {
                        "Ref": "S3DeploymentBucket"
                    },
                    "S3DeploymentRootKey": {
                        "Ref": "S3DeploymentRootKey"
                    },
                    "GetAttGraphQLAPIApiId": {
                        "Fn::GetAtt": [
                            "GraphQLAPI",
                            "ApiId"
                        ]
                    }
                },
                "TemplateURL": {
                    "Fn::Join": [
                        "/",
                        [
                            "https://s3.amazonaws.com",
                            {
                                "Ref": "S3DeploymentBucket"
                            },
                            {
                                "Ref": "S3DeploymentRootKey"
                            },
                            "stacks",
                            "ConnectionStack.json"
                        ]
                    ]
                }
            },
            "DependsOn": [
                "GraphQLSchema",
                "Room",
                "Shade",
                "Scene",
                "Automation",
                "Remote",
                "GatewayCommand",
                "Gateway",
                "Home",
                "SceneAction",
                "RemoteGroup"
            ]
        }
    },
    "Outputs": {
        "GraphQLAPIIdOutput": {
            "Description": "Your GraphQL API ID.",
            "Value": {
                "Fn::GetAtt": [
                    "GraphQLAPI",
                    "ApiId"
                ]
            },
            "Export": {
                "Name": {
                    "Fn::Join": [
                        ":",
                        [
                            {
                                "Ref": "AWS::StackName"
                            },
                            "GraphQLApiId"
                        ]
                    ]
                }
            }
        },
        "GraphQLAPIEndpointOutput": {
            "Description": "Your GraphQL API endpoint.",
            "Value": {
                "Fn::GetAtt": [
                    "GraphQLAPI",
                    "GraphQLUrl"
                ]
            },
            "Export": {
                "Name": {
                    "Fn::Join": [
                        ":",
                        [
                            {
                                "Ref": "AWS::StackName"
                            },
                            "GraphQLApiEndpoint"
                        ]
                    ]
                }
            }
        },
        "GraphQLAPIKeyOutput": {
            "Description": "Your GraphQL API key. Provide via 'x-api-key' header.",
            "Value": {
                "Fn::GetAtt": [
                    "GraphQLAPIKey",
                    "ApiKey"
                ]
            },
            "Export": {
                "Name": {
                    "Fn::Join": [
                        ":",
                        [
                            {
                                "Ref": "AWS::StackName"
                            },
                            "GraphQLApiKey"
                        ]
                    ]
                }
            },
            "Condition": "ShouldCreateAPIKey"
        }
    },
    "Conditions": {
        "ShouldUsePayPerRequestBilling": {
            "Fn::Equals": [
                {
                    "Ref": "DynamoDBBillingMode"
                },
                "PAY_PER_REQUEST"
            ]
        },
        "ShouldUsePointInTimeRecovery": {
            "Fn::Equals": [
                {
                    "Ref": "DynamoDBEnablePointInTimeRecovery"
                },
                "true"
            ]
        },
        "ShouldCreateAPIKey": {
            "Fn::And": [
                {
                    "Fn::Not": [
                        {
                            "Fn::Equals": [
                                {
                                    "Ref": "APIKeyExpirationEpoch"
                                },
                                -1
                            ]
                        }
                    ]
                },
                {
                    "Fn::Equals": [
                        {
                            "Ref": "AuthCognitoUserPoolId"
                        },
                        "NONE"
                    ]
                }
            ]
        },
        "APIKeyExpirationEpochIsPositive": {
            "Fn::And": [
                {
                    "Fn::Not": [
                        {
                            "Fn::Equals": [
                                {
                                    "Ref": "APIKeyExpirationEpoch"
                                },
                                -1
                            ]
                        }
                    ]
                },
                {
                    "Fn::Not": [
                        {
                            "Fn::Equals": [
                                {
                                    "Ref": "APIKeyExpirationEpoch"
                                },
                                0
                            ]
                        }
                    ]
                }
            ]
        },
        "HasEnvironmentParameter": {
            "Fn::Not": [
                {
                    "Fn::Equals": [
                        {
                            "Ref": "env"
                        },
                        "NONE"
                    ]
                }
            ]
        }
    }
}