{
  "AWSTemplateFormatVersion": "2010-09-09",
  "Description": "{\"createdOn\":\"Windows\",\"createdBy\":\"Amplify\",\"createdWith\":\"12.14.0\",\"stackType\":\"function-Lambda\",\"metadata\":{\"whyContinueWithGen1\":\"\"}}",
  "Parameters": {
    "CloudWatchRule": {
      "Type": "String",
      "Default": "NONE",
      "Description": " Schedule Expression"
    },
    "deploymentBucketName": {
      "Type": "String"
    },
    "env": {
      "Type": "String"
    },
    "s3Key": {
      "Type": "String"
    },
    "apiapibigpondApiName": {
      "Type": "String",
      "Default": "apiapibigpondApiName"
    },
    "apiapibigpondApiId": {
      "Type": "String",
      "Default": "apiapibigpondApiId"
    },
    "authbigpond10dd5625UserPoolId": {
      "Type": "String",
      "Default": "authbigpond10dd5625UserPoolId"
    },
    "functionmanageFileProcessTableName": {
      "Type": "String",
      "Default": "functionmanageFileProcessTableName"
    },
    "storagebigpondpuloadsBucketName": {
      "Type": "String",
      "Default": "storagebigpondpuloadsBucketName"
    }
  },
  "Conditions": {
    "ShouldNotCreateEnvResources": {
      "Fn::Equals": [
        {
          "Ref": "env"
        },
        "NONE"
      ]
    }
  },
  "Resources": {
    "LambdaFunction": {
      "Type": "AWS::Lambda::Function",
      "Metadata": {
        "aws:asset:path": "./src",
        "aws:asset:property": "Code"
      },
      "Properties": {
        "Code": {
          "S3Bucket": {
            "Ref": "deploymentBucketName"
          },
          "S3Key": {
            "Ref": "s3Key"
          }
        },
        "Handler": "index.handler",
        "FunctionName": {
          "Fn::If": [
            "ShouldNotCreateEnvResources",
            "tempFileProcessTable",
            {
              "Fn::Join": [
                "",
                [
                  "tempFileProcessTable",
                  "-",
                  {
                    "Ref": "env"
                  }
                ]
              ]
            }
          ]
        },
        "Environment": {
          "Variables": {
            "ENV": {
              "Ref": "env"
            },
            "REGION": {
              "Ref": "AWS::Region"
            },
            "API_APIBIGPOND_APINAME": {
              "Ref": "apiapibigpondApiName"
            },
            "API_APIBIGPOND_APIID": {
              "Ref": "apiapibigpondApiId"
            },
            "AUTH_BIGPOND10DD5625_USERPOOLID": {
              "Ref": "authbigpond10dd5625UserPoolId"
            },
            "FUNCTION_MANAGEFILEPROCESSTABLE_NAME": {
              "Ref": "functionmanageFileProcessTableName"
            },
            "STORAGE_BIGPONDPULOADS_BUCKETNAME": {
              "Ref": "storagebigpondpuloadsBucketName"
            }
          }
        },
        "Role": {
          "Fn::GetAtt": [
            "LambdaExecutionRole",
            "Arn"
          ]
        },
        "Runtime": "nodejs18.x",
        "Layers": [],
        "Timeout": 25
      }
    },
    "LambdaExecutionRole": {
      "Type": "AWS::IAM::Role",
      "Properties": {
        "RoleName": {
          "Fn::If": [
            "ShouldNotCreateEnvResources",
            "bigpondLambdaRole1e4e7ee3",
            {
              "Fn::Join": [
                "",
                [
                  "bigpondLambdaRole1e4e7ee3",
                  "-",
                  {
                    "Ref": "env"
                  }
                ]
              ]
            }
          ]
        },
        "AssumeRolePolicyDocument": {
          "Version": "2012-10-17",
          "Statement": [
            {
              "Effect": "Allow",
              "Principal": {
                "Service": [
                  "lambda.amazonaws.com"
                ]
              },
              "Action": [
                "sts:AssumeRole"
              ]
            }
          ]
        }
      }
    },
    "lambdaexecutionpolicy": {
      "DependsOn": [
        "LambdaExecutionRole"
      ],
      "Type": "AWS::IAM::Policy",
      "Properties": {
        "PolicyName": "lambda-execution-policy",
        "Roles": [
          {
            "Ref": "LambdaExecutionRole"
          }
        ],
        "PolicyDocument": {
          "Version": "2012-10-17",
          "Statement": [
            {
              "Effect": "Allow",
              "Action": [
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:PutLogEvents"
              ],
              "Resource": {
                "Fn::Sub": [
                  "arn:aws:logs:${region}:${account}:log-group:/aws/lambda/${lambda}:log-stream:*",
                  {
                    "region": {
                      "Ref": "AWS::Region"
                    },
                    "account": {
                      "Ref": "AWS::AccountId"
                    },
                    "lambda": {
                      "Ref": "LambdaFunction"
                    }
                  }
                ]
              }
            }
          ]
        }
      }
    },
    "AmplifyResourcesPolicy": {
      "DependsOn": [
        "LambdaExecutionRole"
      ],
      "Type": "AWS::IAM::Policy",
      "Properties": {
        "PolicyName": "amplify-lambda-execution-policy",
        "Roles": [
          {
            "Ref": "LambdaExecutionRole"
          }
        ],
        "PolicyDocument": {
          "Version": "2012-10-17",
          "Statement": [
            {
              "Effect": "Allow",
              "Action": [
                "apigateway:POST",
                "apigateway:PUT",
                "apigateway:GET",
                "apigateway:HEAD",
                "apigateway:OPTIONS",
                "apigateway:PATCH"
              ],
              "Resource": [
                {
                  "Fn::Join": [
                    "",
                    [
                      "arn:aws:apigateway:",
                      {
                        "Ref": "AWS::Region"
                      },
                      "::/restapis/",
                      {
                        "Ref": "apiapibigpondApiName"
                      },
                      "/*"
                    ]
                  ]
                }
              ]
            },
            {
              "Effect": "Allow",
              "Action": [
                "cognito-idp:ConfirmSignUp",
                "cognito-idp:AdminCreateUser",
                "cognito-idp:CreateUserImportJob",
                "cognito-idp:AdminSetUserSettings",
                "cognito-idp:AdminLinkProviderForUser",
                "cognito-idp:CreateIdentityProvider",
                "cognito-idp:AdminConfirmSignUp",
                "cognito-idp:AdminDisableUser",
                "cognito-idp:AdminRemoveUserFromGroup",
                "cognito-idp:SetUserMFAPreference",
                "cognito-idp:SetUICustomization",
                "cognito-idp:SignUp",
                "cognito-idp:VerifyUserAttribute",
                "cognito-idp:SetRiskConfiguration",
                "cognito-idp:StartUserImportJob",
                "cognito-idp:AdminSetUserPassword",
                "cognito-idp:AssociateSoftwareToken",
                "cognito-idp:CreateResourceServer",
                "cognito-idp:RespondToAuthChallenge",
                "cognito-idp:CreateUserPoolClient",
                "cognito-idp:AdminUserGlobalSignOut",
                "cognito-idp:GlobalSignOut",
                "cognito-idp:AddCustomAttributes",
                "cognito-idp:CreateGroup",
                "cognito-idp:CreateUserPool",
                "cognito-idp:AdminForgetDevice",
                "cognito-idp:AdminAddUserToGroup",
                "cognito-idp:AdminRespondToAuthChallenge",
                "cognito-idp:ForgetDevice",
                "cognito-idp:CreateUserPoolDomain",
                "cognito-idp:AdminEnableUser",
                "cognito-idp:AdminUpdateDeviceStatus",
                "cognito-idp:StopUserImportJob",
                "cognito-idp:InitiateAuth",
                "cognito-idp:AdminInitiateAuth",
                "cognito-idp:AdminSetUserMFAPreference",
                "cognito-idp:ConfirmForgotPassword",
                "cognito-idp:SetUserSettings",
                "cognito-idp:VerifySoftwareToken",
                "cognito-idp:AdminDisableProviderForUser",
                "cognito-idp:SetUserPoolMfaConfig",
                "cognito-idp:ChangePassword",
                "cognito-idp:ConfirmDevice",
                "cognito-idp:AdminResetUserPassword",
                "cognito-idp:ResendConfirmationCode",
                "cognito-identity:Describe*",
                "cognito-identity:Get*",
                "cognito-identity:List*",
                "cognito-idp:Describe*",
                "cognito-idp:AdminGetDevice",
                "cognito-idp:AdminGetUser",
                "cognito-idp:AdminList*",
                "cognito-idp:List*",
                "cognito-sync:Describe*",
                "cognito-sync:Get*",
                "cognito-sync:List*",
                "iam:ListOpenIdConnectProviders",
                "iam:ListRoles",
                "sns:ListPlatformApplications",
                "cognito-idp:ForgotPassword",
                "cognito-idp:UpdateAuthEventFeedback",
                "cognito-idp:UpdateResourceServer",
                "cognito-idp:UpdateUserPoolClient",
                "cognito-idp:AdminUpdateUserAttributes",
                "cognito-idp:UpdateUserAttributes",
                "cognito-idp:UpdateUserPoolDomain",
                "cognito-idp:UpdateIdentityProvider",
                "cognito-idp:UpdateGroup",
                "cognito-idp:AdminUpdateAuthEventFeedback",
                "cognito-idp:UpdateDeviceStatus",
                "cognito-idp:UpdateUserPool"
              ],
              "Resource": [
                {
                  "Fn::Join": [
                    "",
                    [
                      "arn:aws:cognito-idp:",
                      {
                        "Ref": "AWS::Region"
                      },
                      ":",
                      {
                        "Ref": "AWS::AccountId"
                      },
                      ":userpool/",
                      "ap-southeast-2_tRyN44wjs"
                    ]
                  ]
                }
              ]
            },
            {
              "Effect": "Allow",
              "Action": [
                "lambda:Create*",
                "lambda:Put*",
                "lambda:Add*",
                "lambda:Get*",
                "lambda:List*",
                "lambda:Invoke*",
                "lambda:Update*"
              ],
              "Resource": [
                {
                  "Fn::Join": [
                    "",
                    [
                      "arn:aws:lambda:",
                      {
                        "Ref": "AWS::Region"
                      },
                      ":",
                      {
                        "Ref": "AWS::AccountId"
                      },
                      ":function:",
                      {
                        "Ref": "functionmanageFileProcessTableName"
                      }
                    ]
                  ]
                }
              ]
            },
            {
              "Effect": "Allow",
              "Action": "s3:ListBucket",
              "Resource": [
                {
                  "Fn::Join": [
                    "",
                    [
                      "arn:aws:s3:::",
                      {
                        "Ref": "storagebigpondpuloadsBucketName"
                      }
                    ]
                  ]
                }
              ]
            },
            {
              "Effect": "Allow",
              "Action": [
                "s3:PutObject",
                "s3:GetObject"
              ],
              "Resource": [
                {
                  "Fn::Join": [
                    "",
                    [
                      "arn:aws:s3:::",
                      {
                        "Ref": "storagebigpondpuloadsBucketName"
                      },
                      "/*"
                    ]
                  ]
                }
              ]
            }
          ]
        }
      }
    }
  },
  "Outputs": {
    "Name": {
      "Value": {
        "Ref": "LambdaFunction"
      }
    },
    "Arn": {
      "Value": {
        "Fn::GetAtt": [
          "LambdaFunction",
          "Arn"
        ]
      }
    },
    "Region": {
      "Value": {
        "Ref": "AWS::Region"
      }
    },
    "LambdaExecutionRole": {
      "Value": {
        "Ref": "LambdaExecutionRole"
      }
    },
    "LambdaExecutionRoleArn": {
      "Value": {
        "Fn::GetAtt": [
          "LambdaExecutionRole",
          "Arn"
        ]
      }
    }
  }
}