Skip to content

Commit

Permalink
Provision DNS service and add as dependency (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
chokoswitch authored Oct 9, 2024
1 parent 7ab082c commit a3666dd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { DataGoogleBillingAccount } from "@cdktf/provider-google/lib/data-google
import { DataGoogleOrganization } from "@cdktf/provider-google/lib/data-google-organization/index.js";
import { DnsManagedZone } from "@cdktf/provider-google/lib/dns-managed-zone/index.js";
import { DnsRecordSet } from "@cdktf/provider-google/lib/dns-record-set/index.js";
import { ProjectService } from "@cdktf/provider-google/lib/project-service/index.js";
import { Fn, type TerraformProvider } from "cdktf";
import { Construct } from "constructs";
import { GcpProject } from "../gcp-project/index.js";
Expand Down Expand Up @@ -129,12 +130,14 @@ export class Bootstrap extends Construct {
project: this.devProject.project.projectId,
name: `alpha-${config.domain.replace(".", "-")}`,
dnsName: `alpha.${config.domain}.`,
dependsOn: [this.devProject.dnsService],
});

const prodDnsZone = new DnsManagedZone(this, "prod-dns-zone", {
project: this.prodProject.project.projectId,
name: config.domain.replace(".", "-"),
dnsName: `${config.domain}.`,
dependsOn: [this.prodProject.dnsService],
});

new DnsRecordSet(this, "prod-alpha-ns-delegate", {
Expand Down
8 changes: 8 additions & 0 deletions src/gcp-project/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ export class GcpProject extends Construct {
*/
public readonly tfstateBucketName: string;

/** The created proejct service for cloud DNS to allow provisioning domains during bootstrap. */
public readonly dnsService: ProjectService;

/** The created {@link IamWorkloadIdentityPool} for authenticating from GitHub actions. */
public readonly githubIdentityPool: IamWorkloadIdentityPool;

Expand Down Expand Up @@ -138,6 +141,11 @@ export class GcpProject extends Construct {
service: "cloudresourcemanager.googleapis.com",
});

this.dnsService = new ProjectService(this, "dns", {
project: this.project.projectId,
service: "dns.googleapis.com",
});

const iam = new ProjectService(this, "iam", {
project: this.project.projectId,
service: "iam.googleapis.com",
Expand Down

0 comments on commit a3666dd

Please sign in to comment.