Skip to content

Commit

Permalink
feat(infra): setting different domain and hostred zone for public.sco…
Browse files Browse the repository at this point in the history
…rer.gitcon.co
  • Loading branch information
nutrina committed Sep 11, 2023
1 parent 100594f commit 934472b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions .github/workflows/api-promote-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ jobs:
DOCKER_GTC_PASSPORT_SCORER_IMAGE: public.ecr.aws/c8n6v8e9/passport-scorer:${{ needs.build-api.outputs.dockerTag }}
DOCKER_GTC_PASSPORT_VERIFIER_IMAGE: public.ecr.aws/c8n6v8e9/passport-verifier:${{ needs.build-verifier.outputs.dockerTag }}
ROUTE_53_ZONE: ${{ secrets.ROUTE53_ZONE_ID }}
ROUTE_53_ZONE_FOR_PUBLIC_DATA: ${{ secrets.ROUTE_53_ZONE_FOR_PUBLIC_DATA }}
DOMAIN: ${{ secrets.DOMAIN }}
SCORER_SERVER_SSM_ARN: ${{ secrets.SCORER_SERVER_SSM_ARN }}
FLOWER_USER: ${{ secrets.FLOWER_USER }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/api-promote-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ jobs:
DOCKER_GTC_PASSPORT_SCORER_IMAGE: public.ecr.aws/t1g3k9q8/passport-scorer:${{ needs.build-api.outputs.dockerTag }}
DOCKER_GTC_PASSPORT_VERIFIER_IMAGE: public.ecr.aws/t1g3k9q8/passport-verifier:${{ needs.build-verifier.outputs.dockerTag }}
ROUTE_53_ZONE: ${{ secrets.ROUTE53_ZONE_ID }}
ROUTE_53_ZONE_FOR_PUBLIC_DATA: ${{ secrets.ROUTE_53_ZONE_FOR_PUBLIC_DATA }}
DOMAIN: ${{ secrets.DOMAIN_STAGING }}
SCORER_SERVER_SSM_ARN: ${{ secrets.SCORER_SERVER_SSM_ARN }}
FLOWER_USER: ${{ secrets.FLOWER_USER }}
Expand Down
26 changes: 10 additions & 16 deletions infra/lib/scorer/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,10 @@ export function createScorerECSService(

export async function createScoreExportBucketAndDomain(
domain: string,
route53Zone: string,
alb: LoadBalancer
route53Zone: string
) {
const scoreBucket = new aws.s3.Bucket(`public.${domain}`, {
bucket: `public.${domain}`,
const scoreBucket = new aws.s3.Bucket(domain, {
bucket: domain,
website: {
indexDocument: "registry_score.jsonl",
},
Expand Down Expand Up @@ -363,23 +362,19 @@ export async function createScoreExportBucketAndDomain(
});

const exportCertificate = new aws.acm.Certificate(
`public.${domain}`,
domain,
{
domainName: `public.${domain}`,
domainName: domain,
validationMethod: "DNS",
},
{ provider: eastRegion }
);

const hostedZoneId = aws.route53
.getZone({ name: domain }, { async: true })
.then((zone) => zone.zoneId);

const publicExportCertificateValidationDomain = new aws.route53.Record(
`public.${domain}-validation`,
`${domain}-validation`,
{
name: exportCertificate.domainValidationOptions[0].resourceRecordName,
zoneId: hostedZoneId,
zoneId: route53Zone,
type: exportCertificate.domainValidationOptions[0].resourceRecordType,
records: [
exportCertificate.domainValidationOptions[0].resourceRecordValue,
Expand Down Expand Up @@ -447,9 +442,9 @@ export async function createScoreExportBucketAndDomain(
{}
);

new aws.route53.Record(`public.${domain}`, {
name: `public.${domain}`,
zoneId: hostedZoneId,
new aws.route53.Record(domain, {
name: domain,
zoneId: route53Zone,
type: "A",
aliases: [
{
Expand All @@ -461,7 +456,6 @@ export async function createScoreExportBucketAndDomain(
});

return {
hostedZoneId,
exportCertificate,
publicExportCertificateValidationDomain,
publicCertificateValidation,
Expand Down
7 changes: 6 additions & 1 deletion infra/prod/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import { createScheduledTask } from "../lib/scorer/scheduledTasks";
// The following vars are not allowed to be undefined, hence the `${...}` magic

let route53Zone = `${process.env["ROUTE_53_ZONE"]}`;
let route53ZoneForPublicData = `${process.env["ROUTE_53_ZONE_FOR_PUBLIC_DATA"]}`;
export const domain = `api.scorer.${process.env["DOMAIN"]}`;
export const publicDataDomain = `public.scorer.${process.env["DOMAIN"]}`;
export const publicServiceUrl = `https://${domain}`;

let SCORER_SERVER_SSM_ARN = `${process.env["SCORER_SERVER_SSM_ARN"]}`;
Expand Down Expand Up @@ -1277,4 +1279,7 @@ export const frequentAlloScorerDataDumpTaskDefinition = createScheduledTask(
envConfig
);

const exportVals = createScoreExportBucketAndDomain(domain, route53Zone, alb);
const exportVals = createScoreExportBucketAndDomain(
publicDataDomain,
route53ZoneForPublicData
);
4 changes: 3 additions & 1 deletion infra/staging/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import { createScheduledTask } from "../lib/scorer/scheduledTasks";
// The following vars are not allowed to be undefined, hence the `${...}` magic

let route53Zone = `${process.env["ROUTE_53_ZONE"]}`;
let route53ZoneForPublicData = `${process.env["ROUTE_53_ZONE_FOR_PUBLIC_DATA"]}`;
export const domain = `api.staging.scorer.${process.env["DOMAIN"]}`;
export const publicDataDomain = `public.staging.scorer.${process.env["DOMAIN"]}`;
export const publicServiceUrl = `https://${domain}`;

let SCORER_SERVER_SSM_ARN = `${process.env["SCORER_SERVER_SSM_ARN"]}`;
Expand Down Expand Up @@ -1169,4 +1171,4 @@ export const frequentAlloScorerDataDumpTaskDefinition = createScheduledTask(
envConfig
);

const exportVals = createScoreExportBucketAndDomain(domain, route53Zone, alb);
const exportVals = createScoreExportBucketAndDomain(publicDataDomain, route53ZoneForPublicData);

0 comments on commit 934472b

Please sign in to comment.