|
| 1 | +import * as cdk from '@aws-cdk/core'; |
| 2 | + |
| 3 | +// SSP Lib |
| 4 | +import * as ssp from '@aws-quickstart/ssp-amazon-eks' |
| 5 | + |
| 6 | +//TODO import * as iam from '@aws-cdk/aws-iam'; |
| 7 | +// import * as route53 from '@aws-cdk/aws-route53'; |
| 8 | + |
| 9 | + |
| 10 | +// Team implementations |
| 11 | +import * as team from '../teams' |
| 12 | +import { valueFromContext } from '@aws-quickstart/ssp-amazon-eks/dist/utils/context-utils'; |
| 13 | +import { EksBlueprint, GlobalResources } from '@aws-quickstart/ssp-amazon-eks'; |
| 14 | +import MultiRegionConstruct from '../multi-region-construct'; |
| 15 | + |
| 16 | +const accountID = process.env.CDK_DEFAULT_ACCOUNT!; |
| 17 | +const gitUrl = 'https://github.com/aws-samples/ssp-eks-workloads.git'; |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +export default class NginxIngressConstruct extends cdk.Construct { |
| 22 | + |
| 23 | + constructor(scope: cdk.Construct, id: string) { |
| 24 | + super(scope, id); |
| 25 | + // Teams for the cluster. |
| 26 | + const teams: Array<ssp.Team> = [ |
| 27 | + new team.TeamPlatform(accountID), |
| 28 | + new team.TeamTroiSetup, |
| 29 | + new team.TeamRikerSetup, |
| 30 | + new team.TeamBurnhamSetup(scope) |
| 31 | + ]; |
| 32 | + |
| 33 | + const subdomain : string = valueFromContext(scope, "dev.subzone.name", "dev.some.example.com"); |
| 34 | + const parentDnsAccountId = this.node.tryGetContext("parent.dns.account")!; |
| 35 | + const parentDomain = valueFromContext(this, "parent.hostedzone.name", "some.example.com"); |
| 36 | + |
| 37 | + EksBlueprint.builder() |
| 38 | + .account(process.env.CDK_DEFAULT_ACCOUNT) |
| 39 | + .region('us-west-2') |
| 40 | + .teams(...teams) |
| 41 | + .resourceProvider(GlobalResources.HostedZone, new ssp.DelegatingHostedZoneProvider({ |
| 42 | + parentDomain, |
| 43 | + subdomain, |
| 44 | + parentDnsAccountId, |
| 45 | + delegatingRoleName: 'DomainOperatorRole', |
| 46 | + wildcardSubdomain: true |
| 47 | + })) |
| 48 | + .resourceProvider(GlobalResources.Certificate, new ssp.CreateCertificateProvider('wildcard-cert', `*.${subdomain}`, GlobalResources.HostedZone)) |
| 49 | + .addOns(new ssp.CalicoAddOn, |
| 50 | + new ssp.AwsLoadBalancerControllerAddOn, |
| 51 | + new ssp.addons.ExternalDnsAddon({ |
| 52 | + hostedZoneResources: [GlobalResources.HostedZone] // you can add more if you register resource providers |
| 53 | + }), |
| 54 | + new ssp.NginxAddOn({ |
| 55 | + internetFacing: true, |
| 56 | + backendProtocol: "tcp", |
| 57 | + externalDnsHostname: subdomain, |
| 58 | + crossZoneEnabled: false, |
| 59 | + certificateResourceName: GlobalResources.Certificate, |
| 60 | + values: { |
| 61 | + controller: { |
| 62 | + service: { |
| 63 | + httpsPort: { |
| 64 | + targetPort: "http" |
| 65 | + } |
| 66 | + } |
| 67 | + } |
| 68 | + } |
| 69 | + }), |
| 70 | + new ssp.ArgoCDAddOn( { |
| 71 | + bootstrapRepo: { |
| 72 | + repoUrl: gitUrl, |
| 73 | + targetRevision: "deployable", |
| 74 | + path: 'envs/dev' |
| 75 | + }, |
| 76 | + adminPasswordSecretName: MultiRegionConstruct.SECRET_ARGO_ADMIN_PWD, |
| 77 | + }), |
| 78 | + new ssp.MetricsServerAddOn, |
| 79 | + new ssp.ClusterAutoScalerAddOn, |
| 80 | + new ssp.ContainerInsightsAddOn ) |
| 81 | + .build(scope, `${id}-blueprint`); |
| 82 | + } |
| 83 | +} |
| 84 | + |
0 commit comments