aws-cdk-lib#App TypeScript Examples

The following examples show how to use aws-cdk-lib#App. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AwsProvider.ts    From lift with MIT License 7 votes vote down vote up
constructor(private readonly serverless: Serverless) {
        this.stackName = serverless.getProvider("aws").naming.getStackName();
        this.app = new App();
        this.stack = new Stack(this.app, undefined, {
            synthesizer: new DefaultStackSynthesizer({
                generateBootstrapVersionRule: false,
            }),
        });
        this.legacyProvider = serverless.getProvider("aws");
        this.naming = this.legacyProvider.naming;
        this.region = serverless.getProvider("aws").getRegion();
        serverless.stack = this.stack;
    }
Example #2
Source File: global-rds.test.ts    From cdk-aurora-globaldatabase with Apache License 2.0 6 votes vote down vote up
test('test create Matser Vpc Public', () => {
  const app = new App();
  const stack = new Stack(app, 'testing-stack', { env: envTokyo });
  const VPCPublic = new ec2.Vpc(stack, 'defaultVpc', {
    natGateways: 0,
    maxAzs: 3,
    subnetConfiguration: [{
      cidrMask: 26,
      name: 'PublicVPC',
      subnetType: ec2.SubnetType.PUBLIC,
    }],
  });
  new GlobalAuroraRDSMaster(stack, 'GlobalAuroraRDS', { vpc: VPCPublic });
  assertions.Template.fromStack(stack).hasResourceProperties('AWS::EC2::Subnet', {
    MapPublicIpOnLaunch: true,
  });
  assertions.Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBInstance', {
    PubliclyAccessible: true,
  });
});
Example #3
Source File: global-rds.test.ts    From cdk-aurora-globaldatabase with Apache License 2.0 6 votes vote down vote up
test('test create Matser RDS', () => {
  const app = new App();
  const stack = new Stack(app, 'testing-stack', { env: envTokyo });
  new GlobalAuroraRDSMaster(stack, 'GlobalAuroraRDS');
  assertions.Template.fromStack(stack).findResources('AWS::RDS::DBCluster');
  assertions.Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBClusterParameterGroup', {
    Family: 'aurora-mysql5.7',
    Parameters: {
      time_zone: 'UTC',
    },
  });
  assertions.Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBInstance', {
    PubliclyAccessible: false,
  });
});
Example #4
Source File: global-rds.test.ts    From cdk-aurora-globaldatabase with Apache License 2.0 6 votes vote down vote up
test('test update Parameter Group', () => {
  const app = new App();
  const stack = new Stack(app, 'testing-stack', { env: envTokyo });;
  new GlobalAuroraRDSMaster(stack, 'GlobalAuroraRDS', {
    parameters: {
      time_zone: MySQLtimeZone.ASIA_TAIPEI,
    },
  });
  assertions.Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBClusterParameterGroup', {
    Parameters: {
      time_zone: 'Asia/Taipei',
    },
  });
});
Example #5
Source File: global-rds.test.ts    From cdk-aurora-globaldatabase with Apache License 2.0 6 votes vote down vote up
test('test update timeZone', () => {
  const app = new App();
  const stack = new Stack(app, 'testing-stack', { env: envTokyo });;
  new GlobalAuroraRDSMaster(stack, 'GlobalAuroraRDS', {
    timeZone: MySQLtimeZone.ASIA_TAIPEI,
  });
  assertions.Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBClusterParameterGroup', {
    Parameters: {
      time_zone: 'Asia/Taipei',
    },
  });
});
Example #6
Source File: rds.test.ts    From bastion-host-forward with Apache License 2.0 6 votes vote down vote up
test('Bastion Host with own securityGroup', () => {
  const app = new App();
  const stack = new Stack(app, 'TestStack');
  const testVpc = new Vpc(stack, 'TestVpc');
  const securityGroup = new SecurityGroup(stack, 'SecurityGroup', {
    vpc: testVpc,
    allowAllOutbound: false,
    description: 'My test securityGroup description',
    securityGroupName: 'MyTestSecurityGroupName',
  });

  const testRds = new DatabaseInstance(stack, 'TestRDS', {
    engine: DatabaseInstanceEngine.POSTGRES,
    instanceType: InstanceType.of(InstanceClass.T3, InstanceSize.MICRO),
    vpc: testVpc,
  });

  // WHEN
  const bastionHost = new BastionHostRDSForward(stack, 'MyTestConstruct', {
    vpc: testVpc,
    name: 'MyBastion',
    rdsInstance: testRds,
    securityGroup,
  });
  const bastionHostSecurityGroup = bastionHost.securityGroup as SecurityGroup;

  assert.equal(securityGroup.securityGroupId, bastionHostSecurityGroup.securityGroupId);
  assert.equal(securityGroup.allowAllOutbound, bastionHostSecurityGroup.allowAllOutbound);
});
Example #7
Source File: global-rds.test.ts    From cdk-aurora-globaldatabase with Apache License 2.0 6 votes vote down vote up
test('test change default dbUserName and default database Name', () => {
  const app = new App();
  const stack = new Stack(app, 'testing-stack', { env: envTokyo });;
  new GlobalAuroraRDSMaster(stack, 'GlobalAuroraRDS', {
    dbUserName: 'superuser',
    defaultDatabaseName: 'superdb',
    rdsPassword: '1qaz2wsx',
  });
  assertions.Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBCluster', {
    Engine: 'aurora-mysql',
    DatabaseName: 'superdb',
    EngineVersion: '5.7.mysql_aurora.2.07.1',
    MasterUsername: 'superuser',
    MasterUserPassword: '1qaz2wsx',
  });
});
Example #8
Source File: global-rds.test.ts    From cdk-aurora-globaldatabase with Apache License 2.0 6 votes vote down vote up
test('test no default rdsPassword', () => {
  const app = new App();
  const stack = new Stack(app, 'testing-stack', { env: envTokyo });;
  new GlobalAuroraRDSMaster(stack, 'GlobalAuroraRDS', {
    defaultDatabaseName: 'superdb',
  });
  assertions.Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBCluster', {
    Engine: 'aurora-mysql',
    DatabaseName: 'superdb',
    EngineVersion: '5.7.mysql_aurora.2.07.1',
    MasterUsername: {
      'Fn::Join': [
        '',
        [
          '{{resolve:secretsmanager:',
          {
            Ref: 'GlobalAuroraRDSRDSClusterSecretE59E7C4B',
          },
          ':SecretString:username::}}',
        ],
      ],
    },
    MasterUserPassword: {
      'Fn::Join': [
        '',
        [
          '{{resolve:secretsmanager:',
          {
            Ref: 'GlobalAuroraRDSRDSClusterSecretE59E7C4B',
          },
          ':SecretString:password::}}',
        ],
      ],
    },
  });
});
Example #9
Source File: generic-bastion-host-forward.test.ts    From bastion-host-forward with Apache License 2.0 6 votes vote down vote up
test('Bastion Host with own securityGroup', () => {
  const app = new App();
  const stack = new Stack(app, 'TestStack');
  const testVpc = new Vpc(stack, 'TestVpc');
  const securityGroup = new SecurityGroup(stack, 'SecurityGroup', {
    vpc: testVpc,
    allowAllOutbound: false,
    description: 'My test securityGroup description',
    securityGroupName: 'MyTestSecurityGroupName',
  });

  // WHEN
  const bastionHost = new GenericBastionHostForward(stack, 'MyTestConstruct', {
    vpc: testVpc,
    name: 'MyRedShiftBastion',
    securityGroup,
    address: '127.0.0.1',
    port: '6379',
  });
  const bastionHostSecurityGroup = bastionHost.securityGroup as SecurityGroup;

  assert.equal(securityGroup.securityGroupId, bastionHostSecurityGroup.securityGroupId);
  assert.equal(securityGroup.allowAllOutbound, bastionHostSecurityGroup.allowAllOutbound);
});
Example #10
Source File: generic-bastion-host-forward.test.ts    From bastion-host-forward with Apache License 2.0 6 votes vote down vote up
test('Bastion Host created for normal access', () => {
  const app = new App();
  const stack = new Stack(app, 'TestStack');
  const testVpc = new Vpc(stack, 'TestVpc');
  // WHEN
  new GenericBastionHostForward(stack, 'MyTestConstruct', {
    vpc: testVpc,
    name: 'MyRedisBastion',
    address: '127.0.0.1',
    port: '6379',
    clientTimeout: 20,
    serverTimeout: 50,
  });

  const template = Template.fromStack(stack);

  // THEN
  template.hasResourceProperties('AWS::EC2::Instance', {
    UserData: {
      'Fn::Base64':
        'Content-Type: multipart/mixed; boundary="//"\nMIME-Version: 1.0\n--//\nContent-Type: text/cloud-config; charset="us-ascii"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\nContent-Disposition: attachment; filename="cloud-config.txt"\n#cloud-config\ncloud_final_modules:\n- [scripts-user, always]\n--//\nContent-Type: text/x-shellscript; charset="us-ascii"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\nContent-Disposition: attachment; filename="userdata.txt"\n#!/bin/bash\nmount -o remount,rw,nosuid,nodev,noexec,relatime,hidepid=2 /proc\nyum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm\nyum install -y haproxy\necho "listen database\n  bind 0.0.0.0:6379\n  timeout connect 10s\n  timeout client 20m\n  timeout server 50m\n  mode tcp\n  server service 127.0.0.1:6379\n" > /etc/haproxy/haproxy.cfg\nservice haproxy restart\n--//',
    },
    Tags: [
      {
        Key: 'Name',
        Value: 'MyRedisBastion',
      },
    ],
  });
});
Example #11
Source File: aurora-serverless.test.ts    From bastion-host-forward with Apache License 2.0 6 votes vote down vote up
test('Bastion Host with own securityGroup', () => {
  const app = new App();
  const stack = new Stack(app, 'TestStack');
  const testVpc = new Vpc(stack, 'TestVpc');
  const securityGroup = new SecurityGroup(stack, 'SecurityGroup', {
    vpc: testVpc,
    allowAllOutbound: false,
    description: 'My test securityGroup description',
    securityGroupName: 'MyTestSecurityGroupName',
  });

  const testAurora = new ServerlessCluster(stack, 'TestAurora', {
    engine: DatabaseClusterEngine.AURORA,
    vpc: testVpc,
  });

  // WHEN
  const bastionHost = new BastionHostAuroraServerlessForward(stack, 'MyTestConstruct', {
    vpc: testVpc,
    name: 'MyBastion',
    serverlessCluster: testAurora,
    securityGroup,
  });
  const bastionHostSecurityGroup = bastionHost.securityGroup as SecurityGroup;

  assert.equal(securityGroup.securityGroupId, bastionHostSecurityGroup.securityGroupId);
  assert.equal(securityGroup.allowAllOutbound, bastionHostSecurityGroup.allowAllOutbound);
});
Example #12
Source File: global-rds.test.ts    From cdk-aurora-globaldatabase with Apache License 2.0 6 votes vote down vote up
test('test create Slave region use self vpc', () => {
  const app = new App();
  const stack = new Stack(app, 'testing-stack', { env: envTokyo });
  const rdsVpcSecond = new ec2.Vpc(stack, 'RDSVpcRegionSlave', {
    cidr: '10.109.0.0/16',
    enableDnsHostnames: true,
    enableDnsSupport: true,
    natGateways: 1,
  });
  new GlobalAuroraRDSSlaveInfra(stack, 'GlobalAuroraRDS', {
    vpc: rdsVpcSecond,
  });
  assertions.Template.fromStack(stack).findResources('AWS::EC2::VPC');
});
Example #13
Source File: global-rds.test.ts    From cdk-aurora-globaldatabase with Apache License 2.0 6 votes vote down vote up
test('test create Slave region vpc use Public Subnet', () => {
  const app = new App();
  const stack = new Stack(app, 'testing-stack', { env: envTokyo });
  new GlobalAuroraRDSSlaveInfra(stack, 'GlobalAuroraRDS', {
    subnetType: ec2.SubnetType.PUBLIC,
  });
  assertions.Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBSubnetGroup', {
    DBSubnetGroupDescription: 'Public Subnets for database',
  });
});
Example #14
Source File: global-rds.test.ts    From cdk-aurora-globaldatabase with Apache License 2.0 6 votes vote down vote up
test('test create Main region vpc use Postgres cluster', () => {
  const app = new App();
  const stack = new Stack(app, 'testing-stack', { env: envTokyo });
  new GlobalAuroraRDSMaster(stack, 'GlobalAuroraRDS', {
    instanceType: InstanceTypeEnum.R5_LARGE,
    rdsPassword: '1qaz2wsx',
    engineVersion: _rds.DatabaseClusterEngine.auroraPostgres({ version: _rds.AuroraPostgresEngineVersion.VER_11_7 }),
    dbClusterpPG: new _rds.ParameterGroup(stack, 'dbClusterparametergroup', {
      engine: _rds.DatabaseClusterEngine.auroraPostgres({
        version: _rds.AuroraPostgresEngineVersion.VER_11_7,
      }),
      parameters: {
        'rds.force_ssl': '1',
        'timezone': 'UTC+8',
      },
    }),
  });
  assertions.Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBCluster', {
    Engine: 'aurora-postgresql',
    DatabaseName: 'globaldatabase',
    MasterUsername: 'sysadmin',
    MasterUserPassword: '1qaz2wsx',
  });
  assertions.Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBClusterParameterGroup', {
    Parameters: {
      'timezone': 'UTC+8',
      'rds.force_ssl': '1',
    },
  });
});
Example #15
Source File: global-rds.test.ts    From cdk-aurora-globaldatabase with Apache License 2.0 6 votes vote down vote up
test('test Create Custom Resource', () => {
  const app = new App();
  const stack = new Stack(app, 'testing-stack', { env: envTokyo });
  new GlobalAuroraRDSMaster(stack, 'GlobalAuroraRDS', {
    instanceType: InstanceTypeEnum.R5_LARGE,
    rdsPassword: '1qaz2wsx',
    engineVersion: _rds.DatabaseClusterEngine.auroraPostgres({ version: _rds.AuroraPostgresEngineVersion.VER_11_7 }),
    dbClusterpPG: new _rds.ParameterGroup(stack, 'dbClusterparametergroup', {
      engine: _rds.DatabaseClusterEngine.auroraPostgres({
        version: _rds.AuroraPostgresEngineVersion.VER_11_7,
      }),
    }),
  });
  assertions.Template.fromStack(stack).findResources('Custom::UpgradeGlobalClusterProvider');
});
Example #16
Source File: global-rds.test.ts    From cdk-aurora-globaldatabase with Apache License 2.0 6 votes vote down vote up
test('test add Regional Function', () => {
  const app = new App();
  const stack = new Stack(app, 'testing-stack', { env: envTokyo });
  const globalmainstack = new GlobalAuroraRDSMaster(stack, 'GlobalAuroraRDS', {
    instanceType: InstanceTypeEnum.R5_LARGE,
    rdsPassword: '1qaz2wsx',
    engineVersion: _rds.DatabaseClusterEngine.auroraPostgres({ version: _rds.AuroraPostgresEngineVersion.VER_11_7 }),
    dbClusterpPG: new _rds.ParameterGroup(stack, 'dbClusterparametergroup', {
      engine: _rds.DatabaseClusterEngine.auroraPostgres({
        version: _rds.AuroraPostgresEngineVersion.VER_11_7,
      }),
    }),
  });

  globalmainstack.addRegionalCluster(stack, 'regional', {
    region: 'ap-southeast-1',
    dbSubnetGroupName: 'mock-db-subnet-group-name',
  });

  assertions.Template.fromStack(stack).findResources('Custom::UpgradeGlobalClusterProvider');
  assertions.Template.fromStack(stack).findResources('Custom::addRegionalClusterProvider');
});
Example #17
Source File: global-rds.test.ts    From cdk-aurora-globaldatabase with Apache License 2.0 6 votes vote down vote up
test('test error Region', () => {
  const app = new App();
  const stack = new Stack(app, 'testing-stack', { env: envErrorRegion });
  expect(()=>{
    const globalmainstack = new GlobalAuroraRDSMaster(stack, 'GlobalAuroraRDS', {
      instanceType: InstanceTypeEnum.R5_LARGE,
      rdsPassword: '1qaz2wsx',
      engineVersion: _rds.DatabaseClusterEngine.auroraPostgres({ version: _rds.AuroraPostgresEngineVersion.VER_11_7 }),
      dbClusterpPG: new _rds.ParameterGroup(stack, 'dbClusterparametergroup', {
        engine: _rds.DatabaseClusterEngine.auroraPostgres({
          version: _rds.AuroraPostgresEngineVersion.VER_11_7,
        }),
      }),
    });

    globalmainstack.addRegionalCluster(stack, 'regional', {
      region: 'ap-southeast-1',
      dbSubnetGroupName: 'mock-db-subnet-group-name',
    });
  }).toThrowError(/This region sa-east-1 not Support Global RDS !!!/);
});
Example #18
Source File: global-rds.test.ts    From cdk-aurora-globaldatabase with Apache License 2.0 5 votes vote down vote up
test('test create Slave region vpc', () => {
  const app = new App();
  const stack = new Stack(app, 'testing-stack', { env: envTokyo });
  new GlobalAuroraRDSSlaveInfra(stack, 'GlobalAuroraRDS');
  assertions.Template.fromStack(stack).findResources('AWS::EC2::VPC');
});
Example #19
Source File: global-rds.test.ts    From cdk-aurora-globaldatabase with Apache License 2.0 5 votes vote down vote up
test('test create Slave region vpc default Private Subnet', () => {
  const app = new App();
  const stack = new Stack(app, 'testing-stack', { env: envTokyo });
  new GlobalAuroraRDSSlaveInfra(stack, 'GlobalAuroraRDS');
  assertions.Template.fromStack(stack).hasResourceProperties('AWS::RDS::DBSubnetGroup', {
    DBSubnetGroupDescription: 'Private Subnets for database',
  });
});
Example #20
Source File: global-rds.test.ts    From cdk-aurora-globaldatabase with Apache License 2.0 5 votes vote down vote up
test('test error Region input addRegional Function', () => {
  const app = new App();
  const stack = new Stack(app, 'testing-stack', { env: envErrorRegion });
  expect(()=>{
    new GlobalAuroraRDSSlaveInfra(stack, 'GlobalAuroraRDS');
    assertions.Template.fromStack(stack).findResources('AWS::EC2::VPC');
  }).toThrowError(/This region sa-east-1 not Support Global RDS !!!/);
});
Example #21
Source File: aws-ec2-imagebuilder-cdk-example.ts    From amazon-ec2-image-builder-samples with MIT No Attribution 5 votes vote down vote up
app = new App()
Example #22
Source File: pipeline-stack.ts    From minwiz with BSD 2-Clause "Simplified" License 5 votes vote down vote up
constructor(app: App, id: string, props: PipelineStackProps) {
    super(app, id, props);

    const siteBuild = new PipelineProject(this, "MinWizBuild", {
      description: "minwiz.com site build",
      buildSpec: BuildSpec.fromObject({
        version: "0.2",
        phases: {
          install: {
            commands: ["npm ci"],
          },
          build: {
            commands: "npm run build",
          },
        },
        artifacts: {
          "base-directory": "dist",
          files: ["**/*"],
        },
      }),
      environment: {
        buildImage: LinuxBuildImage.STANDARD_5_0,
        computeType: ComputeType.SMALL,
      },
    });

    const siteBuildOutput = new Artifact("SiteBuildOutput");

    const sourceOutput = new Artifact("SrcOutput");

    const artifactBucket = new Bucket(this, "MinWizPipelineArtifacts", {
      removalPolicy: RemovalPolicy.DESTROY,
      encryption: BucketEncryption.S3_MANAGED,
      blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
      autoDeleteObjects: true,
    });

    new Pipeline(this, "MinWiz", {
      restartExecutionOnUpdate: true,
      artifactBucket,
      stages: [
        {
          stageName: "Source",
          actions: [
            new GitHubSourceAction({
              actionName: "Checkout",
              output: sourceOutput,
              owner: "zeplia",
              repo: "minwiz",
              oauthToken: SecretValue.plainText(props.githubToken),
              trigger: GitHubTrigger.WEBHOOK,
            }),
          ],
        },
        {
          stageName: "Build",
          actions: [
            new CodeBuildAction({
              actionName: "Site_Build",
              project: siteBuild,
              input: sourceOutput,
              outputs: [siteBuildOutput],
            }),
          ],
        },
        {
          stageName: "Deploy",
          actions: [
            new S3DeployAction({
              actionName: "DeployStaticSite",
              input: siteBuildOutput,
              bucket: props.websiteBucket,
            }),
          ],
        },
      ],
    });
  }
Example #23
Source File: integ.default.ts    From cdk-aurora-globaldatabase with Apache License 2.0 5 votes vote down vote up
mockApp = new App()
Example #24
Source File: rds.test.ts    From bastion-host-forward with Apache License 2.0 5 votes vote down vote up
test('Bastion Host created for normal username/password access', () => {
  const app = new App();
  const stack = new Stack(app, 'TestStack');
  const testVpc = new Vpc(stack, 'TestVpc');
  const testRds = new DatabaseInstance(stack, 'TestRDS', {
    engine: DatabaseInstanceEngine.POSTGRES,
    instanceType: InstanceType.of(InstanceClass.T3, InstanceSize.MICRO),
    vpc: testVpc,
  });

  // WHEN
  new BastionHostRDSForward(stack, 'MyTestConstruct', {
    vpc: testVpc,
    name: 'MyBastion',
    rdsInstance: testRds,
    clientTimeout: 2,
    serverTimeout: 4,
  });

  const template = Template.fromStack(stack);

  // THEN
  template.hasResourceProperties('AWS::EC2::Instance', {
    UserData: {
      'Fn::Base64': {
        'Fn::Join': [
          '',
          [
            'Content-Type: multipart/mixed; boundary="//"\nMIME-Version: 1.0\n--//\nContent-Type: text/cloud-config; charset="us-ascii"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\nContent-Disposition: attachment; filename="cloud-config.txt"\n#cloud-config\ncloud_final_modules:\n- [scripts-user, always]\n--//\nContent-Type: text/x-shellscript; charset="us-ascii"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\nContent-Disposition: attachment; filename="userdata.txt"\n#!/bin/bash\nmount -o remount,rw,nosuid,nodev,noexec,relatime,hidepid=2 /proc\nyum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm\nyum install -y haproxy\necho "listen database\n  bind 0.0.0.0:',
            {
              'Fn::GetAtt': ['TestRDSDF309CB7', 'Endpoint.Port'],
            },
            '\n  timeout connect 10s\n  timeout client 2m\n  timeout server 4m\n  mode tcp\n  server service ',
            {
              'Fn::GetAtt': ['TestRDSDF309CB7', 'Endpoint.Address'],
            },
            ':',
            {
              'Fn::GetAtt': ['TestRDSDF309CB7', 'Endpoint.Port'],
            },
            '\n" > /etc/haproxy/haproxy.cfg\nservice haproxy restart\n--//',
          ],
        ],
      },
    },
    Tags: [
      {
        Key: 'Name',
        Value: 'MyBastion',
      },
    ],
  });
});
Example #25
Source File: aurora-serverless.test.ts    From bastion-host-forward with Apache License 2.0 5 votes vote down vote up
test('Bastion Host created for normal username/password access', () => {
  const app = new App();
  const stack = new Stack(app, 'TestStack');
  const testVpc = new Vpc(stack, 'TestVpc');
  const testAurora = new ServerlessCluster(stack, 'TestAurora', {
    engine: DatabaseClusterEngine.AURORA,
    vpc: testVpc,
  });

  // WHEN
  new BastionHostAuroraServerlessForward(stack, 'MyTestConstruct', {
    vpc: testVpc,
    name: 'MyBastion',
    serverlessCluster: testAurora,
    clientTimeout: 2,
    serverTimeout: 7,
  });

  const template = Template.fromStack(stack);

  // THEN
  template.hasResourceProperties('AWS::EC2::Instance', {
    UserData: {
      'Fn::Base64': {
        'Fn::Join': [
          '',
          [
            'Content-Type: multipart/mixed; boundary="//"\nMIME-Version: 1.0\n--//\nContent-Type: text/cloud-config; charset="us-ascii"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\nContent-Disposition: attachment; filename="cloud-config.txt"\n#cloud-config\ncloud_final_modules:\n- [scripts-user, always]\n--//\nContent-Type: text/x-shellscript; charset="us-ascii"\nMIME-Version: 1.0\nContent-Transfer-Encoding: 7bit\nContent-Disposition: attachment; filename="userdata.txt"\n#!/bin/bash\nmount -o remount,rw,nosuid,nodev,noexec,relatime,hidepid=2 /proc\nyum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm\nyum install -y haproxy\necho "listen database\n  bind 0.0.0.0:',
            {
              'Fn::GetAtt': ['TestAurora252434E9', 'Endpoint.Port'],
            },
            '\n  timeout connect 10s\n  timeout client 2m\n  timeout server 7m\n  mode tcp\n  server service ',
            {
              'Fn::GetAtt': ['TestAurora252434E9', 'Endpoint.Address'],
            },
            ':',
            {
              'Fn::GetAtt': ['TestAurora252434E9', 'Endpoint.Port'],
            },
            '\n" > /etc/haproxy/haproxy.cfg\nservice haproxy restart\n--//',
          ],
        ],
      },
    },
    Tags: [
      {
        Key: 'Name',
        Value: 'MyBastion',
      },
    ],
  });
});
Example #26
Source File: url-shortener.test.ts    From cloudstructs with Apache License 2.0 5 votes vote down vote up
beforeEach(() => {
  app = new App();
  stack = new Stack(app, 'Stack', {
    env: { region: 'eu-west-1' },
  });
});
Example #27
Source File: url-shortener.test.ts    From cloudstructs with Apache License 2.0 5 votes vote down vote up
app: App
Example #28
Source File: url-shortener.integ.ts    From cloudstructs with Apache License 2.0 5 votes vote down vote up
app = new App()
Example #29
Source File: toolkit-cleaner.integ.ts    From cloudstructs with Apache License 2.0 5 votes vote down vote up
app = new App()