How to use where clause in Knex
Create refunds with Stripe
Load HTML with Cheerio
How to send POST request with Axios
Find intersection of array in Lodash
Powered by Official white Bloop logo with a period

Terms / Privacy / Search / Support

  • const app = new App();
    const stack = new Stack(app, 'AwsCdkFsxLustre');
    const vpc = new Vpc(stack, 'VPC');
    
    const lustreConfiguration = {
      deploymentType: LustreDeploymentType.SCRATCH_2,
    };
    const fs = new LustreFileSystem(stack, 'FsxLustreFileSystem', {
      lustreConfiguration,
      storageCapacityGiB: 1200,
      vpc,
      vpcSubnet: vpc.privateSubnets[0]});
    
    const inst = new Instance(stack, 'inst', {
      instanceType: InstanceType.of(InstanceClass.T2, InstanceSize.LARGE),
      machineImage: new AmazonLinuxImage({
        generation: AmazonLinuxGeneration.AMAZON_LINUX_2,
      }),
      vpc,
      vpcSubnets: {
        subnetType: SubnetType.PUBLIC,
      },
    });
    fs.connections.allowDefaultPortFrom(inst);
    
    // Need to give the instance access to read information about FSx to determine the file system's mount name.
    inst.role.addManagedPolicy(ManagedPolicy.fromAwsManagedPolicyName('AmazonFSxReadOnlyAccess'));
    
    const mountPath = '/mnt/fsx';
    const dnsName = fs.dnsName;
    const mountName = fs.mountName;
    
    inst.userData.addCommands(
      'set -eux',
      'yum update -y',
      'amazon-linux-extras install -y lustre2.10',
      // Set up the directory to mount the file system to and change the owner to the AL2 default ec2-user.
      `mkdir -p ${mountPath}`,
      `chmod 777 ${mountPath}`,
      `chown ec2-user:ec2-user ${mountPath}`,
      // Set the file system up to mount automatically on start up and mount it.
      `echo "${dnsName}@tcp:/${mountName} ${mountPath} lustre defaults,noatime,flock,_netdev 0 0" >> /etc/fstab`,
      'mount -a');
    
    Docs
    0
  • const app = new cdk.App();
    const stack = new cdk.Stack(app, 'stack');
    
    Docs
    0
  • const app = new App();
    const stack = new Stack(app, 'AwsCdkFsxLustreImport');
    
    const sg = SecurityGroup.fromSecurityGroupId(stack, 'FsxSecurityGroup', '{SECURITY-GROUP-ID}');
    const fs = LustreFileSystem.fromLustreFileSystemAttributes(stack, 'FsxLustreFileSystem', {
        dnsName: '{FILE-SYSTEM-DNS-NAME}'
        fileSystemId: '{FILE-SYSTEM-ID}',
        securityGroup: sg
    });
    
    const vpc = Vpc.fromVpcAttributes(stack, 'Vpc', {
        availabilityZones: ['us-west-2a', 'us-west-2b'],
        publicSubnetIds: ['{US-WEST-2A-SUBNET-ID}', '{US-WEST-2B-SUBNET-ID}'],
        vpcId: '{VPC-ID}'
    });
    const inst = new Instance(stack, 'inst', {
      instanceType: InstanceType.of(InstanceClass.T2, InstanceSize.LARGE),
      machineImage: new AmazonLinuxImage({
        generation: AmazonLinuxGeneration.AMAZON_LINUX_2
      }),
      vpc,
      vpcSubnets: {
        subnetType: SubnetType.PUBLIC,
      }
    });
    fs.connections.allowDefaultPortFrom(inst);
    
    Docs
    0
  • import { App, CfnOutput, NestedStack, NestedStackProps, Stack } from '@aws-cdk/core';
    import { Construct } from 'constructs';
    import { Deployment, Method, MockIntegration, PassthroughBehavior, RestApi, Stage } from '../lib';
    
    /**
     * This file showcases how to split up a RestApi's Resources and Methods across nested stacks.
     *
     * The root stack 'RootStack' first defines a RestApi.
     * Two nested stacks BooksStack and PetsStack, create corresponding Resources '/books' and '/pets'.
     * They are then deployed to a 'prod' Stage via a third nested stack - DeployStack.
     *
     * To verify this worked, go to the APIGateway
     */
    
    class RootStack extends Stack {
      constructor(scope: Construct) {
        super(scope, 'integ-restapi-import-RootStack');
    
        const restApi = new RestApi(this, 'RestApi', {
          deploy: false,
        });
        restApi.root.addMethod('ANY');
    
        const petsStack = new PetsStack(this, {
          restApiId: restApi.restApiId,
          rootResourceId: restApi.restApiRootResourceId,
        });
        const booksStack = new BooksStack(this, {
          restApiId: restApi.restApiId,
          rootResourceId: restApi.restApiRootResourceId,
        });
        new DeployStack(this, {
          restApiId: restApi.restApiId,
          methods: petsStack.methods.concat(booksStack.methods),
        });
    
        new CfnOutput(this, 'PetsURL', {
          value: `https://${restApi.restApiId}.execute-api.${this.region}.amazonaws.com/prod/pets`,
        });
    
        new CfnOutput(this, 'BooksURL', {
          value: `https://${restApi.restApiId}.execute-api.${this.region}.amazonaws.com/prod/books`,
        });
      }
    }
    
    interface ResourceNestedStackProps extends NestedStackProps {
      readonly restApiId: string;
    
      readonly rootResourceId: string;
    }
    
    class PetsStack extends NestedStack {
      public readonly methods: Method[] = [];
    
      constructor(scope: Construct, props: ResourceNestedStackProps) {
        super(scope, 'integ-restapi-import-PetsStack', props);
    
        const api = RestApi.fromRestApiAttributes(this, 'RestApi', {
          restApiId: props.restApiId,
          rootResourceId: props.rootResourceId,
        });
    
        const method = api.root.addResource('pets').addMethod('GET', new MockIntegration({
          integrationResponses: [{
            statusCode: '200',
          }],
          passthroughBehavior: PassthroughBehavior.NEVER,
          requestTemplates: {
            'application/json': '{ "statusCode": 200 }',
          },
        }), {
          methodResponses: [{ statusCode: '200' }],
        });
    
        this.methods.push(method);
      }
    }
    
    class BooksStack extends NestedStack {
      public readonly methods: Method[] = [];
    
      constructor(scope: Construct, props: ResourceNestedStackProps) {
        super(scope, 'integ-restapi-import-BooksStack', props);
    
        const api = RestApi.fromRestApiAttributes(this, 'RestApi', {
          restApiId: props.restApiId,
          rootResourceId: props.rootResourceId,
        });
    
        const method = api.root.addResource('books').addMethod('GET', new MockIntegration({
          integrationResponses: [{
            statusCode: '200',
          }],
          passthroughBehavior: PassthroughBehavior.NEVER,
          requestTemplates: {
            'application/json': '{ "statusCode": 200 }',
          },
        }), {
          methodResponses: [{ statusCode: '200' }],
        });
    
        this.methods.push(method);
      }
    }
    
    interface DeployStackProps extends NestedStackProps {
      readonly restApiId: string;
    
      readonly methods?: Method[];
    }
    
    class DeployStack extends NestedStack {
      constructor(scope: Construct, props: DeployStackProps) {
        super(scope, 'integ-restapi-import-DeployStack', props);
    
        const deployment = new Deployment(this, 'Deployment', {
          api: RestApi.fromRestApiId(this, 'RestApi', props.restApiId),
        });
        if (props.methods) {
          for (const method of props.methods) {
            deployment.node.addDependency(method);
          }
        }
        new Stage(this, 'Stage', { deployment });
      }
    }
    
    new RootStack(new App());
    
    Docs
    0
  • import * as cdk from '@aws-cdk/core';
    import * as servicediscovery from '../lib';
    
    const app = new cdk.App();
    const stack = new cdk.Stack(app, 'aws-servicediscovery-integ');
    
    const namespace = new servicediscovery.HttpNamespace(stack, 'MyNamespace', {
      name: 'covfefe',
    });
    
    const service1 = namespace.createService('NonIpService', {
      description: 'service registering non-ip instances',
    });
    
    service1.registerNonIpInstance('NonIpInstance', {
      customAttributes: { arn: 'arn:aws:s3:::mybucket' },
    });
    
    const service2 = namespace.createService('IpService', {
      description: 'service registering ip instances',
      healthCheck: {
        type: servicediscovery.HealthCheckType.HTTP,
        resourcePath: '/check',
      },
    });
    
    service2.registerIpInstance('IpInstance', {
      ipv4: '54.239.25.192',
    });
    
    app.synth();
    
    
    Docs
    0
  • // The code below shows an example of how to instantiate this type.
    // The values are placeholders you should change.
    import * as cdk from '@aws-cdk/core';
    
    const fileSystem = new cdk.FileSystem();
    
    Docs
    0
  • // The code below shows an example of how to instantiate this type.
    // The values are placeholders you should change.
    import * as cdk from '@aws-cdk/core';
    
    const tag = new cdk.Tag('key', 'value', /* all optional props */ {
      applyToLaunchedInstances: false,
      excludeResourceTypes: ['excludeResourceTypes'],
      includeResourceTypes: ['includeResourceTypes'],
      priority: 123,
    });
    
    Docs
    0
  • import * as cdk from '@aws-cdk/core';
    
    class MyConstruct extends cdk.Resource implements cdk.ITaggable {
    public readonly tags = new cdk.TagManager(cdk.TagType.KEY_VALUE, 'Whatever::The::Type');
    
    constructor(scope: cdk.Construct, id: string) {
    super(scope, id);
    
    new cdk.CfnResource(this, 'Resource', {
    type: 'Whatever::The::Type',
    properties: {
    // ...
    Tags: this.tags.renderedTags,
    },
    });
    }
    }
    
    Docs
    0
  • // publish lifecycle events to an SNS topic:
    new CustomResource(this, 'MyResource', {
       serviceToken: myTopic.topicArn,
    });
    
    Docs
    0
  • // use the provider framework from aws-cdk/custom-resources:
    const provider = new customresources.Provider(this, 'ResourceProvider', {
       onEventHandler,
       isCompleteHandler, // optional
    });
    
    new CustomResource(this, 'MyResource', {
       serviceToken: provider.serviceToken,
    });
    
    Docs
    0
  • const provider = new customresources.Provider(this, 'MyProvider', {
      onEventHandler,
      isCompleteHandler, // optional async waiter
    });
    
    new CustomResource(this, 'MyResource', {
      serviceToken: provider.serviceToken
    });
    
    Docs
    0
  • declare const myProvider: CustomResourceProvider;
    
    new CustomResource(this, 'MyCustomResource', {
      serviceToken: myProvider.serviceToken,
      properties: {
        myPropertyOne: 'one',
        myPropertyTwo: 'two',
      },
    });
    
    Docs
    0
  • // invoke an AWS Lambda function when a lifecycle event occurs:
    new CustomResource(this, 'MyResource', {
       serviceToken: myFunction.functionArn,
    });
    
    Docs
    0
  • Powered by Official black Bloop logo with a period
    download the IDE extension

    View other examples