Esempio n. 1
0
        public TimestreamService(Construct scope, string id) : base(scope, id)
        {
            var handler = new Function(this, "StepHandler", new FunctionProps
            {
                Runtime = Runtime.NODEJS_10_X,
                Code    = Code.FromAsset("LambdaResources"),
                Handler = "steps.main",
            });
            var db = new CfnDatabase(this, "TimestreamDB", new CfnDatabaseProps
            {
                DatabaseName = "StepDatabase",
            });
            var table = new CfnTable(this, "stepTable", new CfnTableProps()
            {
                TableName    = "StepTable",
                DatabaseName = db.DatabaseName
            });
            var api = new RestApi(this, "Steps-API", new RestApiProps
            {
                RestApiName = "Step Service",
                Description = "This service services Steps."
            });

            var postStepsIntegration = new LambdaIntegration(handler);

            var steps = api.Root.AddResource("healthInput");

            steps.AddMethod("POST", postStepsIntegration);
        }
        internal TimestreamStack(Construct scope, string id, IStackProps props = null) : base(scope, id, props)
        {
            var key      = Alias.FromAliasName(this, "timestream", "alias/aws/timestream");
            var database = new CfnDatabase(this, "sampledb", new CfnDatabaseProps
            {
                DatabaseName = "sampledb",
                KmsKeyId     = key.KeyId,
            });
            var table = new CfnTable(this, "sampletable", new CfnTableProps
            {
                TableName           = "sampletable",
                DatabaseName        = database.DatabaseName,
                RetentionProperties = new Dictionary <string, string>()
                {
                    { "MemoryStoreRetentionPeriodInHours", "24" },
                    { "MagneticStoreRetentionPeriodInDays", "7" }
                },
            });

            table.AddDependsOn(database);
        }