Skip to content

Commit eccc246

Browse files
committed
Add FTP credential capture function
1 parent d7eb363 commit eccc246

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

spire/templates/apps/exchange.yml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,6 +1534,96 @@ Resources:
15341534
Action: lambda:InvokeFunction
15351535
FunctionName: !GetAtt FtpServerAuthorizerFunction.Arn
15361536
Principal: transfer.amazonaws.com
1537+
FtpServerCredentialCaptureFunction:
1538+
Type: AWS::Serverless::Function
1539+
Properties:
1540+
Architectures: [arm64]
1541+
CodeUri:
1542+
Bucket: !Ref CodeS3Bucket
1543+
Key: !Ref FtpAuthorizerLambdaCodeS3ObjectKey
1544+
Description: !Sub ${EnvironmentType} FTP transfer credential capture
1545+
Environment:
1546+
Variables:
1547+
DB_NAME_PARAMETER_ARN: !Sub arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/prx/${EnvironmentTypeAbbreviation}/Spire/Exchange/database-name
1548+
DB_USERNAME_PARAMETER_ARN: !Sub arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/prx/${EnvironmentTypeAbbreviation}/Spire/Exchange/database-username
1549+
DB_PASSWORD_PARAMETER_ARN: !Sub arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/prx/${EnvironmentTypeAbbreviation}/Spire/Exchange/database-password
1550+
MYSQL_ENDPOINT: !Ref SharedAuroraMysqlEndpoint
1551+
ENCRYPTION_SECRET_PARAMETER_ARN: !Sub arn:aws:ssm:${AWS::Region}:${AWS::AccountId}:parameter/prx/${EnvironmentTypeAbbreviation}/Spire/Exchange/database-name
1552+
Events:
1553+
ScheduleTrigger:
1554+
Properties:
1555+
Schedule: rate(15 minutes)
1556+
State: ENABLED
1557+
Type: Schedule
1558+
Handler: capture.handler
1559+
MemorySize: 512
1560+
Policies:
1561+
- Statement:
1562+
- Action: ssm:Get*
1563+
Effect: Allow
1564+
Resource: !Sub arn:${AWS::Partition}:ssm:${AWS::Region}:${AWS::AccountId}:parameter/prx/${EnvironmentTypeAbbreviation}/Spire/Exchange/*
1565+
Sid: AllowParameterReadOnly
1566+
Runtime: nodejs24.x
1567+
Tags:
1568+
prx:meta:tagging-version: "2021-04-07"
1569+
prx:cloudformation:stack-name: !Ref AWS::StackName
1570+
prx:cloudformation:stack-id: !Ref AWS::StackId
1571+
prx:cloudformation:root-stack-name: !Ref RootStackName
1572+
prx:cloudformation:root-stack-id: !Ref RootStackId
1573+
prx:ops:environment: !Ref EnvironmentType
1574+
prx:dev:application: Exchange
1575+
Timeout: 60
1576+
VpcConfig:
1577+
SecurityGroupIds:
1578+
- !GetAtt FtpServerAuthorizerFunctionSecurityGroup.GroupId
1579+
- !Ref SharedMysqlClientSecurityGroupId
1580+
SubnetIds:
1581+
- !Ref VpcPrivateSubnet1Id
1582+
- !Ref VpcPrivateSubnet2Id
1583+
- !Ref VpcPrivateSubnet3Id
1584+
FtpServerCredentialCaptureFunctionElevatedErrorAlarm:
1585+
Type: AWS::CloudWatch::Alarm
1586+
Condition: IsProduction
1587+
Properties:
1588+
AlarmName: !Sub WARN [Exchange] FTP credential capture function <${EnvironmentTypeAbbreviation}> INVOCATIONS ERRORS (${RootStackName})
1589+
AlarmDescription: !Sub >-
1590+
${EnvironmentType} Exchange FTP Server credential capture Lambda
1591+
function is failing, which could be preventing stations from pulling
1592+
audio files if any credentials change.
1593+
ComparisonOperator: GreaterThanThreshold
1594+
Dimensions:
1595+
- Name: FunctionName
1596+
Value: !Ref FtpServerCredentialCaptureFunction
1597+
EvaluationPeriods: 1
1598+
MetricName: Errors
1599+
Namespace: AWS/Lambda
1600+
Period: 60
1601+
Statistic: Sum
1602+
Tags:
1603+
- { Key: prx:meta:tagging-version, Value: "2021-04-07" }
1604+
- { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
1605+
- { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId }
1606+
- { Key: prx:cloudformation:root-stack-name, Value: !Ref RootStackName }
1607+
- { Key: prx:cloudformation:root-stack-id, Value: !Ref RootStackId }
1608+
- { Key: prx:ops:environment, Value: !Ref EnvironmentType }
1609+
- { Key: prx:dev:application, Value: Exchange }
1610+
Threshold: 0
1611+
TreatMissingData: notBreaching
1612+
FtpServerCredentialCaptureFunctionLogGroup:
1613+
Type: AWS::Logs::LogGroup
1614+
DeletionPolicy: Delete
1615+
UpdateReplacePolicy: Delete
1616+
Properties:
1617+
LogGroupName: !Sub /aws/lambda/${FtpServerCredentialCaptureFunction}
1618+
RetentionInDays: 14
1619+
Tags:
1620+
- { Key: prx:meta:tagging-version, Value: "2021-04-07" }
1621+
- { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
1622+
- { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId }
1623+
- { Key: prx:cloudformation:root-stack-name, Value: !Ref RootStackName }
1624+
- { Key: prx:cloudformation:root-stack-id, Value: !Ref RootStackId }
1625+
- { Key: prx:ops:environment, Value: !Ref EnvironmentType }
1626+
- { Key: prx:dev:application, Value: Exchange }
15371627
FtpServerLoggingRole:
15381628
Type: AWS::IAM::Role
15391629
Properties:

0 commit comments

Comments
 (0)