Skip to content

Commit 4353efe

Browse files
committed
OLH-3840 create amc stubs
1 parent 7f5ae1a commit 4353efe

File tree

2 files changed

+150
-0
lines changed

2 files changed

+150
-0
lines changed

src/amc/amc-routes.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { APIGatewayProxyEvent } from "aws-lambda";
2+
3+
export const handler = async (event: APIGatewayProxyEvent) => {
4+
if (event.path === "/status") {
5+
return {
6+
statusCode: 200,
7+
body: JSON.stringify({}),
8+
};
9+
}
10+
11+
return {
12+
statusCode: 404,
13+
body: JSON.stringify({ error: "Not Found" }),
14+
};
15+
};

template.yaml

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,3 +1268,138 @@ Resources:
12681268
LogGroupName: !Sub "/aws/lambda/${Environment}-${AWS::StackName}-method-management-delete-v1"
12691269
RetentionInDays: 30
12701270
KmsKeyId: !GetAtt LoggingKmsKey.Arn
1271+
1272+
######################################
1273+
# AMC Stub API
1274+
######################################
1275+
AmcStubsRestApi:
1276+
Type: AWS::Serverless::Api
1277+
Properties:
1278+
AlwaysDeploy: true
1279+
PropagateTags: true
1280+
Name: amc-api-stub
1281+
Description: HTTP API stub for Account Management Client
1282+
StageName: !Ref Environment
1283+
CacheClusterEnabled: true
1284+
CacheClusterSize: "0.5"
1285+
MethodSettings:
1286+
- HttpMethod: "*"
1287+
CachingEnabled: false
1288+
ResourcePath: /*
1289+
TracingEnabled: true
1290+
AccessLogSetting:
1291+
DestinationArn: !GetAtt AmcApiGatewayApiLogGroup.Arn
1292+
Tags:
1293+
FMSRegionalPolicy: false
1294+
CustomPolicy: true
1295+
1296+
AmcApiGatewayApiLogGroup:
1297+
Type: AWS::Logs::LogGroup
1298+
Properties:
1299+
LogGroupName: !Sub "/aws/apigateway/${AmcStubsRestApi}"
1300+
RetentionInDays: 30
1301+
KmsKeyId: !GetAtt LoggingKmsKey.Arn
1302+
1303+
AmcCustomDomain:
1304+
Type: AWS::ApiGatewayV2::DomainName
1305+
Properties:
1306+
DomainName: !Sub amc-stub.home.${Environment}.account.gov.uk
1307+
DomainNameConfigurations:
1308+
- CertificateArn: !Sub "{{resolve:ssm:/${Environment}/Platform/ACM/HostedZone/Certificate/Home/ARN}}"
1309+
EndpointType: REGIONAL
1310+
SecurityPolicy: TLS_1_2
1311+
1312+
AmcApiRecord:
1313+
Type: AWS::Route53::RecordSet
1314+
Properties:
1315+
Name: !Ref AmcCustomDomain
1316+
Type: A
1317+
HostedZoneId: !Sub "{{resolve:ssm:/${Environment}/Platform/Route53/HostedZone/Home}}"
1318+
AliasTarget:
1319+
DNSName: !GetAtt AmcCustomDomain.RegionalDomainName
1320+
HostedZoneId: !GetAtt AmcCustomDomain.RegionalHostedZoneId
1321+
EvaluateTargetHealth: true
1322+
1323+
AmcApiMapping:
1324+
Type: AWS::ApiGateway::BasePathMapping
1325+
Properties:
1326+
DomainName: !Ref AmcCustomDomain
1327+
Stage: !Ref Environment
1328+
RestApiId: !Ref AmcStubsRestApi
1329+
DependsOn:
1330+
- AmcStubsRestApiStage
1331+
1332+
AmcStubEndpoint:
1333+
Type: AWS::SSM::Parameter
1334+
Properties:
1335+
Description: The API Gateway endpoint for the AMC stub
1336+
Name: !Sub "/${AWS::StackName}/Stub/AMC"
1337+
Type: String
1338+
Value: !Sub amc-stub.home.${Environment}.account.gov.uk
1339+
1340+
AmcLambdaRole:
1341+
Type: AWS::IAM::Role
1342+
Properties:
1343+
PermissionsBoundary: !If
1344+
- UsePermissionsBoundary
1345+
- !Ref PermissionsBoundary
1346+
- !Ref AWS::NoValue
1347+
ManagedPolicyArns:
1348+
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
1349+
- arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole
1350+
AssumeRolePolicyDocument:
1351+
Version: "2012-10-17"
1352+
Statement:
1353+
- Effect: Allow
1354+
Principal:
1355+
Service:
1356+
- lambda.amazonaws.com
1357+
Action:
1358+
- "sts:AssumeRole"
1359+
1360+
AmcApiStubFunction:
1361+
Type: AWS::Serverless::Function
1362+
DependsOn:
1363+
- AmcApiStubFunctionLogGroup
1364+
Properties:
1365+
FunctionName: !Sub ${Environment}-${AWS::StackName}-amc
1366+
Architectures: ["arm64"]
1367+
CodeUri: src
1368+
Handler: amc-routes.handler
1369+
KmsKeyArn: !GetAtt LambdaKMSKey.Arn
1370+
PackageType: Zip
1371+
MemorySize: 128
1372+
ReservedConcurrentExecutions: 30
1373+
Role: !GetAtt AmcLambdaRole.Arn
1374+
Timeout: 5
1375+
Events:
1376+
status:
1377+
Type: Api
1378+
Properties:
1379+
Path: /status
1380+
Method: GET
1381+
RestApiId:
1382+
Ref: AmcStubsRestApi
1383+
VpcConfig:
1384+
SubnetIds:
1385+
- Fn::ImportValue: !Sub ${VpcStackName}-PrivateSubnetIdA
1386+
- Fn::ImportValue: !Sub ${VpcStackName}-PrivateSubnetIdB
1387+
SecurityGroupIds:
1388+
- Fn::ImportValue: !Sub ${VpcStackName}-AWSServicesEndpointSecurityGroupId
1389+
Metadata:
1390+
BuildMethod: esbuild
1391+
BuildProperties:
1392+
Minify: true
1393+
Target: "es2020"
1394+
Sourcemap: true
1395+
EntryPoints:
1396+
- amc/amc-routes.ts
1397+
1398+
AmcApiStubFunctionLogGroup:
1399+
Type: AWS::Logs::LogGroup
1400+
DeletionPolicy: Delete
1401+
UpdateReplacePolicy: Delete
1402+
Properties:
1403+
LogGroupName: !Sub "/aws/lambda/${Environment}-${AWS::StackName}-amc"
1404+
RetentionInDays: 30
1405+
KmsKeyId: !GetAtt LoggingKmsKey.Arn

0 commit comments

Comments
 (0)