Skip to content

Commit

Permalink
feat: add paths to apigateway
Browse files Browse the repository at this point in the history
  • Loading branch information
marnixdessing committed Jun 5, 2023
1 parent 5394558 commit e7b5c04
Showing 1 changed file with 56 additions and 10 deletions.
66 changes: 56 additions & 10 deletions src/ContainerCluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,59 @@ export class ContainerClusterStack extends Stack {
const vpcLinkSecurityGroup = this.setupVpcLinkSecurityGroup(vpc);
const vpcLink = this.setupVpcLink(vpc, vpcLinkSecurityGroup);

this.addIssueService(cluster, namespace, api, vpcLink, vpc, vpcLinkSecurityGroup);
// Setup services and api gateway routes
const yiviIssueIntegration = this.addIssueServiceAndIntegration(cluster, namespace, vpcLink, vpc, vpcLinkSecurityGroup);
this.setupApiRoutes(api, yiviIssueIntegration);

}

setupApiRoutes(
api: apigatewayv2.HttpApi,
integration: apigatewayv2Integrations.HttpServiceDiscoveryIntegration
){

// Public
api.addRoutes({
authorizer: new apigatewayv2.HttpNoneAuthorizer(),
path: '/irma/{proxy+}',
methods: [apigatewayv2.HttpMethod.ANY],
integration: integration,
});

// Private paths below
api.addRoutes({
path: '/session',
methods: [apigatewayv2.HttpMethod.POST],
integration: integration,
});



api.addRoutes({
path: '/session/{token}',
methods: [apigatewayv2.HttpMethod.DELETE],
integration: integration,
});

api.addRoutes({
path: '/session/{token}/result',
methods: [apigatewayv2.HttpMethod.GET],
integration: integration,
});

api.addRoutes({
path: '/session/{token}/status',
methods: [apigatewayv2.HttpMethod.GET],
integration: integration,
});

// Dont thinks this is required as we have no events support in apigateway
// api.addRoutes({
// path: '/session/{token}/statusevents',
// methods: [apigatewayv2.HttpMethod.GET],
// integration: integration,
// });

}

setupVpc() {
Expand Down Expand Up @@ -197,10 +249,9 @@ export class ContainerClusterStack extends Stack {
return listner;
}

addIssueService(
addIssueServiceAndIntegration(
cluster: ecs.Cluster,
namespace: servicediscovery.PrivateDnsNamespace,
api: apigatewayv2.HttpApi,
vpcLink: apigatewayv2.VpcLink,
vpc: ec2.IVpc,
vpcLinkSecurityGroup: ec2.SecurityGroup,
Expand Down Expand Up @@ -237,15 +288,10 @@ export class ContainerClusterStack extends Stack {
securityGroups: [sg],
});

api.addRoutes({
path: '/irma',
methods: [apigatewayv2.HttpMethod.ANY],
integration: new apigatewayv2Integrations.HttpServiceDiscoveryIntegration('api-integration', cloudMapsService, {
vpcLink,
}),
return new apigatewayv2Integrations.HttpServiceDiscoveryIntegration('api-integration', cloudMapsService, {
vpcLink,
});


}

createYiviKey() {
Expand Down

0 comments on commit e7b5c04

Please sign in to comment.