Skip to content

Instantly share code, notes, and snippets.

View SlootSantos's full-sized avatar
😎
Rollin'

Flosloot SlootSantos

😎
Rollin'
View GitHub Profile
// updated application-stack.ts class
// note the buildSanityCheckCodeBuild method
import { Construct } from "constructs";
import { CfnOutput, Stage, StageProps } from "aws-cdk-lib";
import { BuildSpec, ComputeType } from "aws-cdk-lib/aws-codebuild";
import { CodeBuildStep, CodePipelineSource } from "aws-cdk-lib/pipelines";
import { DelegatedDomainStack } from "../stacks/application-stack";
#!/bin/bash
set -e
# making sure we read the NAME_SERVER variable from the CDK CFN output as an array
IFS=' ' read -r -a NS_ARRAY <<< "$DELEGATED_NAME_SERVERS"
# storing the name servers from the dig request as an array too
DIG_RESULT=($(dig +short NS ${DELEGATED_DOMAIN_NAME}))
for nsEntry in ${DIG_RESULT[@]};
do
import {
AwsCustomResource,
AwsCustomResourcePolicy,
PhysicalResourceId,
} from "aws-cdk-lib/custom-resources";
import { Construct } from "constructs";
import { CfnOutput, Fn } from "aws-cdk-lib";
import { IHostedZone } from "aws-cdk-lib/aws-route53";
import { domains } from "../../constants/domains";
import { Construct } from "constructs";
import { Stage, StageProps } from "aws-cdk-lib";
import { DelegatedDomainStack } from "../stacks/application-stack";
interface DelegatedDomainPipelineStageProps extends StageProps {
stage: "dev" | "prod";
}
export class DelegatedDomainPipelineStage extends Stage {
constructor(
import { Construct } from "constructs";
import { CfnOutput, Stack, StackProps } from "aws-cdk-lib";
import { buildDelegatedDomainHostedZone } from "../services/Route53/delegatedDomainHostedZone";
import { buildDelegatedNameServerRecord } from "../services/CustomResources/delegatedNameServerRecord";
import { domains } from "../constants/domains";
interface DelegatedDomainStackProps extends StackProps {
stageConfig: {
stage: "dev" | "prod";
import { Construct } from "constructs";
import {
Role,
Effect,
PolicyDocument,
PolicyStatement,
AccountPrincipal,
CompositePrincipal,
} from "aws-cdk-lib/aws-iam";
import { IHostedZone } from "aws-cdk-lib/aws-route53";
package main
import (
"log"
"os"
"path/filepath"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
exports.handler = async (event, context, callback) => {
const request = event.Records[0].cf.request;
request.uri = "/content" + request.uri;
return callback(null, request);
};
func createCloudfrontDistro(s *session.Session, functionARN string) {
cdnHandler := cloudfront.New(s)
config := &cloudfront.CreateDistributionInput{
DistributionConfig: &cloudfront.DistributionConfig{
CallerReference: aws.String(bucketNameOrigin),
Comment: aws.String(bucketNameOrigin),
Enabled: aws.Bool(true),
Origins: &cloudfront.Origins{ // here we tell cloudfront that we want to use a Bucket as origin
Quantity: aws.Int64(1),
package main
import (
"log"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/iam"
"github.com/aws/aws-sdk-go/service/lambda"
"github.com/aws/aws-sdk-go/service/s3"