From d5d4202a70852fd70e7110b511f8b9eebe9ca9ef Mon Sep 17 00:00:00 2001 From: Yiming Luo Date: Tue, 6 Aug 2024 18:50:09 -0400 Subject: [PATCH] fix: Move Go module to another repo --- .gitignore | 3 +- .projenrc.js | 9 +- dist/go/ddcdkconstruct/Datadog.go | 202 ---------- dist/go/ddcdkconstruct/DatadogProps.go | 45 --- dist/go/ddcdkconstruct/DatadogStrictProps.go | 31 -- dist/go/ddcdkconstruct/Datadog__checks.go | 116 ------ dist/go/ddcdkconstruct/Datadog__no_checks.go | 38 -- dist/go/ddcdkconstruct/LICENSE | 202 ---------- dist/go/ddcdkconstruct/NOTICE | 4 - dist/go/ddcdkconstruct/Node.go | 7 - dist/go/ddcdkconstruct/README.md | 377 ------------------ dist/go/ddcdkconstruct/Runtime.go | 7 - dist/go/ddcdkconstruct/RuntimeType.go | 14 - dist/go/ddcdkconstruct/TagKeys.go | 12 - dist/go/ddcdkconstruct/Transport.go | 180 --------- dist/go/ddcdkconstruct/Transport__checks.go | 34 -- .../go/ddcdkconstruct/Transport__no_checks.go | 18 - dist/go/ddcdkconstruct/go.mod | 12 - dist/go/ddcdkconstruct/internal/types.go | 5 - dist/go/ddcdkconstruct/jsii/jsii.go | 28 -- dist/go/ddcdkconstruct/main.go | 84 ---- dist/go/ddcdkconstruct/version | 1 - package.json | 2 +- 23 files changed, 3 insertions(+), 1428 deletions(-) delete mode 100644 dist/go/ddcdkconstruct/Datadog.go delete mode 100644 dist/go/ddcdkconstruct/DatadogProps.go delete mode 100644 dist/go/ddcdkconstruct/DatadogStrictProps.go delete mode 100644 dist/go/ddcdkconstruct/Datadog__checks.go delete mode 100644 dist/go/ddcdkconstruct/Datadog__no_checks.go delete mode 100644 dist/go/ddcdkconstruct/LICENSE delete mode 100644 dist/go/ddcdkconstruct/NOTICE delete mode 100644 dist/go/ddcdkconstruct/Node.go delete mode 100644 dist/go/ddcdkconstruct/README.md delete mode 100644 dist/go/ddcdkconstruct/Runtime.go delete mode 100644 dist/go/ddcdkconstruct/RuntimeType.go delete mode 100644 dist/go/ddcdkconstruct/TagKeys.go delete mode 100644 dist/go/ddcdkconstruct/Transport.go delete mode 100644 dist/go/ddcdkconstruct/Transport__checks.go delete mode 100644 dist/go/ddcdkconstruct/Transport__no_checks.go delete mode 100644 dist/go/ddcdkconstruct/go.mod delete mode 100644 dist/go/ddcdkconstruct/internal/types.go delete mode 100644 dist/go/ddcdkconstruct/jsii/jsii.go delete mode 100644 dist/go/ddcdkconstruct/main.go delete mode 100644 dist/go/ddcdkconstruct/version diff --git a/.gitignore b/.gitignore index d44cdccc4..3a115eb97 100644 --- a/.gitignore +++ b/.gitignore @@ -54,10 +54,9 @@ junit.xml !/tsconfig.dev.json !/src/ /lib +/dist/ !/.eslintrc.json .jsii tsconfig.json !integration_tests/tsconfig.json -dist/* -!dist/go !/.projenrc.js diff --git a/.projenrc.js b/.projenrc.js index 6ebe373ab..7ef256b9f 100644 --- a/.projenrc.js +++ b/.projenrc.js @@ -21,7 +21,7 @@ const project = new awscdk.AwsCdkConstructLibrary({ module: "datadog_cdk_constructs_v2", }, publishToGo: { - moduleName: "github.com/DataDog/datadog-cdk-constructs/dist/go", + moduleName: "github.com/DataDog/datadog-cdk-constructs-go", packageName: "ddcdkconstruct", }, peerDeps: [], @@ -109,13 +109,6 @@ eslintConfig.addOverride("rules", { project.addGitIgnore("!integration_tests/tsconfig.json"); -// Remove the auto-added "dist" folder -project.gitignore.removePatterns("/dist/"); -// The two lines below makes git track "dist/go" and ignore all other folders -// under "dist/" -project.gitignore.addPatterns("dist/*"); -project.gitignore.include("!dist/go"); - // Collapse the generated Go package on GitHub project.gitattributes.addAttributes("/dist/go/** linguist-generated"); diff --git a/dist/go/ddcdkconstruct/Datadog.go b/dist/go/ddcdkconstruct/Datadog.go deleted file mode 100644 index 5dc3b0c60..000000000 --- a/dist/go/ddcdkconstruct/Datadog.go +++ /dev/null @@ -1,202 +0,0 @@ -package ddcdkconstruct - -import ( - _jsii_ "github.com/aws/jsii-runtime-go/runtime" - _init_ "github.com/DataDog/datadog-cdk-constructs/dist/go/ddcdkconstruct/jsii" - - "github.com/aws/aws-cdk-go/awscdk/v2/awslogs" - "github.com/aws/constructs-go/constructs/v10" - "github.com/DataDog/datadog-cdk-constructs/dist/go/ddcdkconstruct/internal" -) - -type Datadog interface { - constructs.Construct - // The tree node. - Node() constructs.Node - Props() *DatadogProps - SetProps(val *DatadogProps) - Scope() constructs.Construct - SetScope(val constructs.Construct) - Transport() Transport - SetTransport(val Transport) - AddForwarderToNonLambdaLogGroups(logGroups *[]awslogs.ILogGroup) - AddGitCommitMetadata(lambdaFunctions *[]interface{}, gitCommitSha *string, gitRepoUrl *string) - AddLambdaFunctions(lambdaFunctions *[]interface{}, construct constructs.Construct) - // Returns a string representation of this construct. - ToString() *string -} - -// The jsii proxy struct for Datadog -type jsiiProxy_Datadog struct { - internal.Type__constructsConstruct -} - -func (j *jsiiProxy_Datadog) Node() constructs.Node { - var returns constructs.Node - _jsii_.Get( - j, - "node", - &returns, - ) - return returns -} - -func (j *jsiiProxy_Datadog) Props() *DatadogProps { - var returns *DatadogProps - _jsii_.Get( - j, - "props", - &returns, - ) - return returns -} - -func (j *jsiiProxy_Datadog) Scope() constructs.Construct { - var returns constructs.Construct - _jsii_.Get( - j, - "scope", - &returns, - ) - return returns -} - -func (j *jsiiProxy_Datadog) Transport() Transport { - var returns Transport - _jsii_.Get( - j, - "transport", - &returns, - ) - return returns -} - - -func NewDatadog(scope constructs.Construct, id *string, props *DatadogProps) Datadog { - _init_.Initialize() - - if err := validateNewDatadogParameters(scope, id, props); err != nil { - panic(err) - } - j := jsiiProxy_Datadog{} - - _jsii_.Create( - "datadog-cdk-constructs-v2.Datadog", - []interface{}{scope, id, props}, - &j, - ) - - return &j -} - -func NewDatadog_Override(d Datadog, scope constructs.Construct, id *string, props *DatadogProps) { - _init_.Initialize() - - _jsii_.Create( - "datadog-cdk-constructs-v2.Datadog", - []interface{}{scope, id, props}, - d, - ) -} - -func (j *jsiiProxy_Datadog)SetProps(val *DatadogProps) { - if err := j.validateSetPropsParameters(val); err != nil { - panic(err) - } - _jsii_.Set( - j, - "props", - val, - ) -} - -func (j *jsiiProxy_Datadog)SetScope(val constructs.Construct) { - if err := j.validateSetScopeParameters(val); err != nil { - panic(err) - } - _jsii_.Set( - j, - "scope", - val, - ) -} - -func (j *jsiiProxy_Datadog)SetTransport(val Transport) { - if err := j.validateSetTransportParameters(val); err != nil { - panic(err) - } - _jsii_.Set( - j, - "transport", - val, - ) -} - -// Checks if `x` is a construct. -// -// Returns: true if `x` is an object created from a class which extends `Construct`. -// Deprecated: use `x instanceof Construct` instead. -func Datadog_IsConstruct(x interface{}) *bool { - _init_.Initialize() - - if err := validateDatadog_IsConstructParameters(x); err != nil { - panic(err) - } - var returns *bool - - _jsii_.StaticInvoke( - "datadog-cdk-constructs-v2.Datadog", - "isConstruct", - []interface{}{x}, - &returns, - ) - - return returns -} - -func (d *jsiiProxy_Datadog) AddForwarderToNonLambdaLogGroups(logGroups *[]awslogs.ILogGroup) { - if err := d.validateAddForwarderToNonLambdaLogGroupsParameters(logGroups); err != nil { - panic(err) - } - _jsii_.InvokeVoid( - d, - "addForwarderToNonLambdaLogGroups", - []interface{}{logGroups}, - ) -} - -func (d *jsiiProxy_Datadog) AddGitCommitMetadata(lambdaFunctions *[]interface{}, gitCommitSha *string, gitRepoUrl *string) { - if err := d.validateAddGitCommitMetadataParameters(lambdaFunctions); err != nil { - panic(err) - } - _jsii_.InvokeVoid( - d, - "addGitCommitMetadata", - []interface{}{lambdaFunctions, gitCommitSha, gitRepoUrl}, - ) -} - -func (d *jsiiProxy_Datadog) AddLambdaFunctions(lambdaFunctions *[]interface{}, construct constructs.Construct) { - if err := d.validateAddLambdaFunctionsParameters(lambdaFunctions); err != nil { - panic(err) - } - _jsii_.InvokeVoid( - d, - "addLambdaFunctions", - []interface{}{lambdaFunctions, construct}, - ) -} - -func (d *jsiiProxy_Datadog) ToString() *string { - var returns *string - - _jsii_.Invoke( - d, - "toString", - nil, // no parameters - &returns, - ) - - return returns -} - diff --git a/dist/go/ddcdkconstruct/DatadogProps.go b/dist/go/ddcdkconstruct/DatadogProps.go deleted file mode 100644 index 0f8cad073..000000000 --- a/dist/go/ddcdkconstruct/DatadogProps.go +++ /dev/null @@ -1,45 +0,0 @@ -package ddcdkconstruct - -import ( - "github.com/aws/aws-cdk-go/awscdk/v2/awssecretsmanager" -) - -type DatadogProps struct { - AddLayers *bool `field:"optional" json:"addLayers" yaml:"addLayers"` - ApiKey *string `field:"optional" json:"apiKey" yaml:"apiKey"` - ApiKeySecret awssecretsmanager.ISecret `field:"optional" json:"apiKeySecret" yaml:"apiKeySecret"` - ApiKeySecretArn *string `field:"optional" json:"apiKeySecretArn" yaml:"apiKeySecretArn"` - ApiKmsKey *string `field:"optional" json:"apiKmsKey" yaml:"apiKmsKey"` - ApmFlushDeadline interface{} `field:"optional" json:"apmFlushDeadline" yaml:"apmFlushDeadline"` - CaptureLambdaPayload *bool `field:"optional" json:"captureLambdaPayload" yaml:"captureLambdaPayload"` - ColdStartTraceSkipLibs *string `field:"optional" json:"coldStartTraceSkipLibs" yaml:"coldStartTraceSkipLibs"` - CreateForwarderPermissions *bool `field:"optional" json:"createForwarderPermissions" yaml:"createForwarderPermissions"` - DecodeAuthorizerContext *bool `field:"optional" json:"decodeAuthorizerContext" yaml:"decodeAuthorizerContext"` - DotnetLayerVersion *float64 `field:"optional" json:"dotnetLayerVersion" yaml:"dotnetLayerVersion"` - EnableColdStartTracing *bool `field:"optional" json:"enableColdStartTracing" yaml:"enableColdStartTracing"` - EnableDatadogASM *bool `field:"optional" json:"enableDatadogASM" yaml:"enableDatadogASM"` - EnableDatadogLogs *bool `field:"optional" json:"enableDatadogLogs" yaml:"enableDatadogLogs"` - EnableDatadogTracing *bool `field:"optional" json:"enableDatadogTracing" yaml:"enableDatadogTracing"` - EnableMergeXrayTraces *bool `field:"optional" json:"enableMergeXrayTraces" yaml:"enableMergeXrayTraces"` - EnableProfiling *bool `field:"optional" json:"enableProfiling" yaml:"enableProfiling"` - EncodeAuthorizerContext *bool `field:"optional" json:"encodeAuthorizerContext" yaml:"encodeAuthorizerContext"` - Env *string `field:"optional" json:"env" yaml:"env"` - ExtensionLayerVersion *float64 `field:"optional" json:"extensionLayerVersion" yaml:"extensionLayerVersion"` - FlushMetricsToLogs *bool `field:"optional" json:"flushMetricsToLogs" yaml:"flushMetricsToLogs"` - ForwarderArn *string `field:"optional" json:"forwarderArn" yaml:"forwarderArn"` - GrantSecretReadAccess *bool `field:"optional" json:"grantSecretReadAccess" yaml:"grantSecretReadAccess"` - InjectLogContext *bool `field:"optional" json:"injectLogContext" yaml:"injectLogContext"` - JavaLayerVersion *float64 `field:"optional" json:"javaLayerVersion" yaml:"javaLayerVersion"` - LogLevel *string `field:"optional" json:"logLevel" yaml:"logLevel"` - MinColdStartTraceDuration *float64 `field:"optional" json:"minColdStartTraceDuration" yaml:"minColdStartTraceDuration"` - NodeLayerVersion *float64 `field:"optional" json:"nodeLayerVersion" yaml:"nodeLayerVersion"` - PythonLayerVersion *float64 `field:"optional" json:"pythonLayerVersion" yaml:"pythonLayerVersion"` - RedirectHandler *bool `field:"optional" json:"redirectHandler" yaml:"redirectHandler"` - Service *string `field:"optional" json:"service" yaml:"service"` - Site *string `field:"optional" json:"site" yaml:"site"` - SourceCodeIntegration *bool `field:"optional" json:"sourceCodeIntegration" yaml:"sourceCodeIntegration"` - Tags *string `field:"optional" json:"tags" yaml:"tags"` - UseLayersFromAccount *string `field:"optional" json:"useLayersFromAccount" yaml:"useLayersFromAccount"` - Version *string `field:"optional" json:"version" yaml:"version"` -} - diff --git a/dist/go/ddcdkconstruct/DatadogStrictProps.go b/dist/go/ddcdkconstruct/DatadogStrictProps.go deleted file mode 100644 index d94829592..000000000 --- a/dist/go/ddcdkconstruct/DatadogStrictProps.go +++ /dev/null @@ -1,31 +0,0 @@ -package ddcdkconstruct - -import ( - "github.com/aws/aws-cdk-go/awscdk/v2/awssecretsmanager" -) - -type DatadogStrictProps struct { - AddLayers *bool `field:"required" json:"addLayers" yaml:"addLayers"` - CaptureLambdaPayload *bool `field:"required" json:"captureLambdaPayload" yaml:"captureLambdaPayload"` - EnableDatadogASM *bool `field:"required" json:"enableDatadogASM" yaml:"enableDatadogASM"` - EnableDatadogLogs *bool `field:"required" json:"enableDatadogLogs" yaml:"enableDatadogLogs"` - EnableDatadogTracing *bool `field:"required" json:"enableDatadogTracing" yaml:"enableDatadogTracing"` - EnableMergeXrayTraces *bool `field:"required" json:"enableMergeXrayTraces" yaml:"enableMergeXrayTraces"` - GrantSecretReadAccess *bool `field:"required" json:"grantSecretReadAccess" yaml:"grantSecretReadAccess"` - InjectLogContext *bool `field:"required" json:"injectLogContext" yaml:"injectLogContext"` - ApiKey *string `field:"optional" json:"apiKey" yaml:"apiKey"` - ApiKeySecret awssecretsmanager.ISecret `field:"optional" json:"apiKeySecret" yaml:"apiKeySecret"` - ApiKeySecretArn *string `field:"optional" json:"apiKeySecretArn" yaml:"apiKeySecretArn"` - ApiKmsKey *string `field:"optional" json:"apiKmsKey" yaml:"apiKmsKey"` - ExtensionLayerVersion *float64 `field:"optional" json:"extensionLayerVersion" yaml:"extensionLayerVersion"` - FlushMetricsToLogs *bool `field:"optional" json:"flushMetricsToLogs" yaml:"flushMetricsToLogs"` - ForwarderArn *string `field:"optional" json:"forwarderArn" yaml:"forwarderArn"` - JavaLayerVersion *float64 `field:"optional" json:"javaLayerVersion" yaml:"javaLayerVersion"` - LogLevel *string `field:"optional" json:"logLevel" yaml:"logLevel"` - NodeLayerVersion *float64 `field:"optional" json:"nodeLayerVersion" yaml:"nodeLayerVersion"` - PythonLayerVersion *float64 `field:"optional" json:"pythonLayerVersion" yaml:"pythonLayerVersion"` - RedirectHandler *bool `field:"optional" json:"redirectHandler" yaml:"redirectHandler"` - Site *string `field:"optional" json:"site" yaml:"site"` - SourceCodeIntegration *bool `field:"optional" json:"sourceCodeIntegration" yaml:"sourceCodeIntegration"` -} - diff --git a/dist/go/ddcdkconstruct/Datadog__checks.go b/dist/go/ddcdkconstruct/Datadog__checks.go deleted file mode 100644 index 59d943cce..000000000 --- a/dist/go/ddcdkconstruct/Datadog__checks.go +++ /dev/null @@ -1,116 +0,0 @@ -//go:build !no_runtime_type_checking - -package ddcdkconstruct - -import ( - "fmt" - - _jsii_ "github.com/aws/jsii-runtime-go/runtime" - - "github.com/aws/aws-cdk-go/awscdk/v2/awslambda" - "github.com/aws/aws-cdk-go/awscdk/v2/awslogs" - "github.com/aws/constructs-go/constructs/v10" -) - -func (d *jsiiProxy_Datadog) validateAddForwarderToNonLambdaLogGroupsParameters(logGroups *[]awslogs.ILogGroup) error { - if logGroups == nil { - return fmt.Errorf("parameter logGroups is required, but nil was provided") - } - - return nil -} - -func (d *jsiiProxy_Datadog) validateAddGitCommitMetadataParameters(lambdaFunctions *[]interface{}) error { - if lambdaFunctions == nil { - return fmt.Errorf("parameter lambdaFunctions is required, but nil was provided") - } - for idx_e8e072, v := range *lambdaFunctions { - switch v.(type) { - case awslambda.Function: - // ok - case awslambda.SingletonFunction: - // ok - default: - if !_jsii_.IsAnonymousProxy(v) { - return fmt.Errorf("parameter lambdaFunctions[%#v] must be one of the allowed types: awslambda.Function, awslambda.SingletonFunction; received %#v (a %T)", idx_e8e072, v, v) - } - } - } - - return nil -} - -func (d *jsiiProxy_Datadog) validateAddLambdaFunctionsParameters(lambdaFunctions *[]interface{}) error { - if lambdaFunctions == nil { - return fmt.Errorf("parameter lambdaFunctions is required, but nil was provided") - } - for idx_e8e072, v := range *lambdaFunctions { - switch v.(type) { - case awslambda.Function: - // ok - case awslambda.SingletonFunction: - // ok - default: - if !_jsii_.IsAnonymousProxy(v) { - return fmt.Errorf("parameter lambdaFunctions[%#v] must be one of the allowed types: awslambda.Function, awslambda.SingletonFunction; received %#v (a %T)", idx_e8e072, v, v) - } - } - } - - return nil -} - -func validateDatadog_IsConstructParameters(x interface{}) error { - if x == nil { - return fmt.Errorf("parameter x is required, but nil was provided") - } - - return nil -} - -func (j *jsiiProxy_Datadog) validateSetPropsParameters(val *DatadogProps) error { - if val == nil { - return fmt.Errorf("parameter val is required, but nil was provided") - } - if err := _jsii_.ValidateStruct(val, func() string { return "parameter val" }); err != nil { - return err - } - - return nil -} - -func (j *jsiiProxy_Datadog) validateSetScopeParameters(val constructs.Construct) error { - if val == nil { - return fmt.Errorf("parameter val is required, but nil was provided") - } - - return nil -} - -func (j *jsiiProxy_Datadog) validateSetTransportParameters(val Transport) error { - if val == nil { - return fmt.Errorf("parameter val is required, but nil was provided") - } - - return nil -} - -func validateNewDatadogParameters(scope constructs.Construct, id *string, props *DatadogProps) error { - if scope == nil { - return fmt.Errorf("parameter scope is required, but nil was provided") - } - - if id == nil { - return fmt.Errorf("parameter id is required, but nil was provided") - } - - if props == nil { - return fmt.Errorf("parameter props is required, but nil was provided") - } - if err := _jsii_.ValidateStruct(props, func() string { return "parameter props" }); err != nil { - return err - } - - return nil -} - diff --git a/dist/go/ddcdkconstruct/Datadog__no_checks.go b/dist/go/ddcdkconstruct/Datadog__no_checks.go deleted file mode 100644 index ef70984f5..000000000 --- a/dist/go/ddcdkconstruct/Datadog__no_checks.go +++ /dev/null @@ -1,38 +0,0 @@ -//go:build no_runtime_type_checking - -package ddcdkconstruct - -// Building without runtime type checking enabled, so all the below just return nil - -func (d *jsiiProxy_Datadog) validateAddForwarderToNonLambdaLogGroupsParameters(logGroups *[]awslogs.ILogGroup) error { - return nil -} - -func (d *jsiiProxy_Datadog) validateAddGitCommitMetadataParameters(lambdaFunctions *[]interface{}) error { - return nil -} - -func (d *jsiiProxy_Datadog) validateAddLambdaFunctionsParameters(lambdaFunctions *[]interface{}) error { - return nil -} - -func validateDatadog_IsConstructParameters(x interface{}) error { - return nil -} - -func (j *jsiiProxy_Datadog) validateSetPropsParameters(val *DatadogProps) error { - return nil -} - -func (j *jsiiProxy_Datadog) validateSetScopeParameters(val constructs.Construct) error { - return nil -} - -func (j *jsiiProxy_Datadog) validateSetTransportParameters(val Transport) error { - return nil -} - -func validateNewDatadogParameters(scope constructs.Construct, id *string, props *DatadogProps) error { - return nil -} - diff --git a/dist/go/ddcdkconstruct/LICENSE b/dist/go/ddcdkconstruct/LICENSE deleted file mode 100644 index d64569567..000000000 --- a/dist/go/ddcdkconstruct/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/dist/go/ddcdkconstruct/NOTICE b/dist/go/ddcdkconstruct/NOTICE deleted file mode 100644 index c694b12d6..000000000 --- a/dist/go/ddcdkconstruct/NOTICE +++ /dev/null @@ -1,4 +0,0 @@ -Datadog datadog-cdk-constructs -Copyright 2021 Datadog, Inc. - -This product includes software developed at Datadog (https://www.datadoghq.com/). diff --git a/dist/go/ddcdkconstruct/Node.go b/dist/go/ddcdkconstruct/Node.go deleted file mode 100644 index 6ab7c3bb6..000000000 --- a/dist/go/ddcdkconstruct/Node.go +++ /dev/null @@ -1,7 +0,0 @@ -package ddcdkconstruct - - -type Node struct { - DefaultChild interface{} `field:"required" json:"defaultChild" yaml:"defaultChild"` -} - diff --git a/dist/go/ddcdkconstruct/README.md b/dist/go/ddcdkconstruct/README.md deleted file mode 100644 index 7f266e009..000000000 --- a/dist/go/ddcdkconstruct/README.md +++ /dev/null @@ -1,377 +0,0 @@ -# Datadog CDK Constructs - -[![NPM](https://img.shields.io/npm/v/datadog-cdk-constructs?color=blue&label=npm+cdk+v1)](https://www.npmjs.com/package/datadog-cdk-constructs) -[![NPM](https://img.shields.io/npm/v/datadog-cdk-constructs-v2?color=39a356&label=npm+cdk+v2)](https://www.npmjs.com/package/datadog-cdk-constructs-v2) -[![PyPI](https://img.shields.io/pypi/v/datadog-cdk-constructs?color=blue&label=pypi+cdk+v1)](https://pypi.org/project/datadog-cdk-constructs/) -[![PyPI](https://img.shields.io/pypi/v/datadog-cdk-constructs-v2?color=39a356&label=pypi+cdk+v2)](https://pypi.org/project/datadog-cdk-constructs-v2/) -[![License](https://img.shields.io/badge/license-Apache--2.0-blue)](https://github.com/DataDog/datadog-cdk-constructs/blob/main/LICENSE) - -Use this Datadog CDK Construct Library to deploy serverless applications using AWS CDK . - -This CDK library automatically configures ingestion of metrics, traces, and logs from your serverless applications by: - -* Installing and configuring the Datadog Lambda layers for your [.NET](https://docs.datadoghq.com/serverless/aws_lambda/installation/dotnet), [Java](https://docs.datadoghq.com/serverless/installation/java/?tab=awscdk), [Node.js](https://github.com/DataDog/datadog-lambda-layer-js), and [Python](https://github.com/DataDog/datadog-lambda-layer-python) Lambda functions. -* Enabling the collection of traces and custom metrics from your Lambda functions. -* Managing subscriptions from the Datadog Forwarder to your Lambda and non-Lambda log groups. - -## AWS CDK v1 vs AWS CDK v2 - -**WARNING**: `AWS CDK v1` has reached end-of-support and `datadog-cdk-constructs` will no longer be receiving updates. It's strongly recommended to upgrade to `AWS CDK v2` ([official migration guide](https://docs.aws.amazon.com/cdk/v2/guide/migrating-v2.html)) and switch to using `datadog-cdk-constructs-v2`. - -Two separate versions of Datadog CDK Constructs exist; `datadog-cdk-constructs` and `datadog-cdk-constructs-v2`. These are designed to work with `AWS CDK v1` and `AWS CDK v2` respectively. - -* `datadog-cdk-constructs-v2` requires Node >= 14, while `datadog-cdk-constructs` supports Node >= 12. -* `datadog-cdk-constructs-v2` contains more features. -* Otherwise, the use of the two packages is identical. - -## npm Package Installation: - -For use with AWS CDK v2: - -``` -yarn add --dev datadog-cdk-constructs-v2 -# or -npm install datadog-cdk-constructs-v2 --save-dev -``` - -For use with AWS CDK v1: - -``` -yarn add --dev datadog-cdk-constructs -# or -npm install datadog-cdk-constructs --save-dev -``` - -## PyPI Package Installation: - -For use with AWS CDK v2: - -``` -pip install datadog-cdk-constructs-v2 -``` - -For use with AWS CDK v1: - -``` -pip install datadog-cdk-constructs -``` - -### Note: - -Pay attention to the output from your package manager as the `Datadog CDK Construct Library` has peer dependencies. - -## Usage - -### AWS CDK - -* *If you are new to AWS CDK then check out this [workshop](https://cdkworkshop.com/15-prerequisites.html).* -* *The following examples assume the use of AWS CDK v2. If you're using CDK v1, import `datadog-cdk-constructs` rather than `datadog-cdk-constructs-v2`.* - -Add this to your CDK stack: - -```go -import { Datadog } from "datadog-cdk-constructs-v2"; - -const datadog = new Datadog(this, "Datadog", { - nodeLayerVersion: , - pythonLayerVersion: , - javaLayerVersion: , - dotnetLayerVersion: - addLayers: , - extensionLayerVersion: "", - forwarderArn: "", - createForwarderPermissions: , - flushMetricsToLogs: , - site: "", - apiKey: "{Datadog_API_Key}", - apiKeySecretArn: "{Secret_ARN_Datadog_API_Key}", - apiKeySecret: , // Only available in datadog-cdk-constructs-v2 - apiKmsKey: "{Encrypted_Datadog_API_Key}", - enableDatadogTracing: , - enableMergeXrayTraces: , - enableDatadogLogs: , - injectLogContext: , - logLevel: , - env: , //Optional - service: , //Optional - version: , //Optional - tags: , //Optional -}); -datadog.addLambdaFunctions([]) -datadog.addForwarderToNonLambdaLogGroups([]) -``` - -## Source Code Integration - -[Source code integration](https://docs.datadoghq.com/integrations/guide/source-code-integration/) is enabled by default through automatic lambda tagging, and will work if: - -* The Datadog Github Integration is installed. -* Your datadog-cdk dependency satisfies either of the below versions: - - * `datadog-cdk-constructs-v2` >= 1.4.0 - * `datadog-cdk-constructs` >= 0.8.5 - -### Alternative Methods to Enable Source Code Integration - -If the automatic implementation doesn't work for your case, please follow one of the two guides below. - -**Note: these alternate guides only work for Typescript.** - -
- datadog-cdk version satisfied, but Datadog Github Integration NOT installed - -If the Datadog Github Integration is not installed, you need to import the `datadog-ci` package and manually upload your Git metadata to Datadog. -We recommend you do this where your CDK Stack is initialized. - -```go -const app = new cdk.App(); - -// Make sure to add @datadog/datadog-ci via your package manager -const datadogCi = require("@datadog/datadog-ci"); -// Manually uploading Git metadata to Datadog. -datadogCi.gitMetadata.uploadGitCommitHash('{Datadog_API_Key}', '') - -const app = new cdk.App(); -new ExampleStack(app, "ExampleStack", {}); - -app.synth(); -``` - -
-
- datadog-cdk version NOT satisfied - -Change your initialization function as follows (note: we're changing this to pass just the `gitHash` value to the CDK): - -```go -async function main() { - // Make sure to add @datadog/datadog-ci via your package manager - const datadogCi = require("@datadog/datadog-ci"); - const [, gitHash] = await datadogCi.gitMetadata.uploadGitCommitHash('{Datadog_API_Key}', '') - - const app = new cdk.App(); - // Pass in the hash to the ExampleStack constructor - new ExampleStack(app, "ExampleStack", {}, gitHash); -} -``` - -Ensure you call this function to initialize your stack. - -In your stack constructor, change to add an optional `gitHash` parameter, and call `addGitCommitMetadata()`: - -```go -export class ExampleStack extends cdk.Stack { - constructor(scope: cdk.App, id: string, props?: cdk.StackProps, gitHash?: string) { - ... - ... - datadog.addGitCommitMetadata([], gitHash) - } -} -``` - -
- -## Configuration - -To further configure your Datadog construct, use the following custom parameters: - -*Note*: The descriptions use the npm package parameters, but they also apply to the PyPI package parameters. - -| npm package parameter | PyPI package parameter | Description | -| --- | --- | --- | -| `addLayers` | `add_layers` | Whether to add the Lambda Layers or expect the user to bring their own. Defaults to `true`. When `true`, the Lambda Library version variables are also required. When `false`, you must include the Datadog Lambda library in your functions' deployment packages. | -| `pythonLayerVersion` | `python_layer_version` | Version of the Python Lambda layer to install, such as `83`. Required if you are deploying at least one Lambda function written in Python and `addLayers` is `true`. Find the latest version number [here](https://github.com/DataDog/datadog-lambda-python/releases). | -| `nodeLayerVersion` | `node_layer_version` | Version of the Node.js Lambda layer to install, such as `100`. Required if you are deploying at least one Lambda function written in Node.js and `addLayers` is `true`. Find the latest version number from [here](https://github.com/DataDog/datadog-lambda-js/releases). | -| `javaLayerVersion` | `java_layer_version` | Version of the Java layer to install, such as `8`. Required if you are deploying at least one Lambda function written in Java and `addLayers` is `true`. Find the latest version number in the [Serverless Java installation documentation](https://docs.datadoghq.com/serverless/installation/java/?tab=awscdk). **Note**: `extensionLayerVersion >= 25` and `javaLayerVersion >= 5` are required for the Datadog construct to instrument your Java functions properly. | -| `dotnetLayerVersion` | `dotnet_layer_version` | Version of the .NET layer to install, such as `13`. Required if you are deploying at least one Lambda function written in .NET and `addLayers` is `true`. Find the latest version number from [here](https://github.com/DataDog/dd-trace-dotnet-aws-lambda-layer/releases). | -| `extensionLayerVersion` | `extension_layer_version` | Version of the Datadog Lambda Extension layer to install, such as 5. When `extensionLayerVersion` is set, `apiKey` (or if encrypted, `apiKMSKey` or `apiKeySecretArn`) needs to be set as well. When enabled, lambda function log groups will not be subscribed by the forwarder. Learn more about the Lambda extension [here](https://docs.datadoghq.com/serverless/datadog_lambda_library/extension/). | -| `forwarderArn` | `forwarder_arn` | When set, the plugin will automatically subscribe the Datadog Forwarder to the functions' log groups. Do not set `forwarderArn` when `extensionLayerVersion` is set. | -| `createForwarderPermissions` | `createForwarderPermissions` | When set to `true`, creates a Lambda permission on the the Datadog Forwarder per log group. Since the Datadog Forwarder has permissions configured by default, this is unnecessary in most use cases. | -| `flushMetricsToLogs` | `flush_metrics_to_logs` | Send custom metrics using CloudWatch logs with the Datadog Forwarder Lambda function (recommended). Defaults to `true` . If you disable this parameter, it's required to set `apiKey` (or if encrypted, `apiKMSKey` or `apiKeySecretArn`). | -| `site` | `site` | Set which Datadog site to send data. This is only used when `flushMetricsToLogs` is `false` or `extensionLayerVersion` is set. Possible values are `datadoghq.com`, `datadoghq.eu`, `us3.datadoghq.com`, `us5.datadoghq.com`, `ap1.datadoghq.com`, and `ddog-gov.com`. The default is `datadoghq.com`. | -| `apiKey` | `api_key` | Datadog API Key, only needed when `flushMetricsToLogs` is `false` or `extensionLayerVersion` is set. For more information about getting a Datadog API key, see the [API key documentation](https://docs.datadoghq.com/account_management/api-app-keys/#api-keys). | -| `apiKeySecretArn` | `api_key_secret_arn` | The ARN of the secret storing the Datadog API key in AWS Secrets Manager. Use this parameter in place of `apiKey` when `flushMetricsToLogs` is `false` or `extensionLayer` is set. Remember to add the `secretsmanager:GetSecretValue` permission to the Lambda execution role. | -| `apiKeySecret` | `api_key_secret` | An [AWS CDK ISecret](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_secretsmanager.ISecret.html) representing a secret storing the Datadog API key in AWS Secrets Manager. Use this parameter in place of `apiKeySecretArn` to automatically grant your Lambda execution roles read access to the given secret. [See here](#automatically-grant-aws-secret-read-access-to-lambda-execution-role) for an example. **Only available in datadog-cdk-constructs-v2**. | -| `apiKmsKey` | `api_kms_key` | Datadog API Key encrypted using KMS. Use this parameter in place of `apiKey` when `flushMetricsToLogs` is `false` or `extensionLayerVersion` is set, and you are using KMS encryption. | -| `enableDatadogTracing` | `enable_datadog_tracing` | Enable Datadog tracing on your Lambda functions. Defaults to `true`. | -| `enableMergeXrayTraces` | `enable_merge_xray_traces` | Enable merging X-Ray traces on your Lambda functions. Defaults to `false`. | -| `enableDatadogLogs` | `enable_datadog_logs` | Send Lambda function logs to Datadog via the Datadog Lambda Extension. Defaults to `true`. Note: This setting has no effect on logs sent via the Datadog Forwarder. | -| `enableSourceCodeIntegration` | `enable_source_code_integration` | Enable Datadog Source Code Integration, connecting your telemetry with application code in your Git repositories. This requires the Datadog Github Integration to work, otherwise please follow the [alternative method](#alternative-methods-to-enable-source-code-integration). Learn more [here](https://docs.datadoghq.com/integrations/guide/source-code-integration/). Defaults to `true`. | -| `injectLogContext` | `inject_log_context` | When set, the Lambda layer will automatically patch console.log with Datadog's tracing ids. Defaults to `true`. | -| `logLevel` | `log_level` | When set to `debug`, the Datadog Lambda Library and Extension will log additional information to help troubleshoot issues. | -| `env` | `env` | When set along with `extensionLayerVersion`, a `DD_ENV` environment variable is added to all Lambda functions with the provided value. When set along with `forwarderArn`, an `env` tag is added to all Lambda functions with the provided value. | -| `service` | `service` | When set along with `extensionLayerVersion`, a `DD_SERVICE` environment variable is added to all Lambda functions with the provided value. When set along with `forwarderArn`, a `service` tag is added to all Lambda functions with the provided value. | -| `version` | `version` | When set along with `extensionLayerVersion`, a `DD_VERSION` environment variable is added to all Lambda functions with the provided value. When set along with `forwarderArn`, a `version` tag is added to all Lambda functions with the provided value. | -| `tags` | `tags` | A comma separated list of key:value pairs as a single string. When set along with `extensionLayerVersion`, a `DD_TAGS` environment variable is added to all Lambda functions with the provided value. When set along with `forwarderArn`, the cdk parses the string and sets each key:value pair as a tag to all Lambda functions. | -| `enableColdStartTracing` | `enable_cold_start_tracing` | Set to `false` to disable Cold Start Tracing. Used in Node.js and Python. Defaults to `true`. | -| `coldStartTraceMinDuration` | `min_cold_start_trace_duration` | Sets the minimum duration (in milliseconds) for a module load event to be traced via Cold Start Tracing. Number. Defaults to `3`. | -| `coldStartTraceSkipLibs` | `cold_start_trace_skip_libs`| Optionally skip creating Cold Start Spans for a comma-separated list of libraries. Useful to limit depth or skip known libraries. Default depends on runtime. | -| `enableProfiling` | `enable_profiling` | Enable the Datadog Continuous Profiler with `true`. Supported in Beta for Node.js and Python. Defaults to `false`. | -| `encodeAuthorizerContext` |`encode_authorizer_context` | When set to `true` for Lambda authorizers, the tracing context will be encoded into the response for propagation. Supported for Node.js and Python. Defaults to `true`. | -| `decodeAuthorizerContext` |`decode_authorizer_context` | When set to `true` for Lambdas that are authorized via Lambda authorizers, it will parse and use the encoded tracing context (if found). Supported for Node.js and Python. Defaults to `true`. | -| `apmFlushDeadline` | `apm_flush_deadline` | Used to determine when to submit spans before a timeout occurs, in milliseconds. When the remaining time in an AWS Lambda invocation is less than the value set, the tracer attempts to submit the current active spans and all finished spans. Supported for Node.js and Python. Defaults to `100` milliseconds. | -| `redirectHandler` | `redirect_handler` | When set to `false`, skip redirecting handler to the Datadog Lambda Library's handler. Useful when only instrumenting with Datadog Lambda Extension. Defaults to `true`. | - -**Note**: Using the parameters above may override corresponding function level `DD_XXX` environment variables. - -### Tracing - -Enable X-Ray Tracing on your Lambda functions. For more information, see [CDK documentation](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-lambda.Tracing.html). - -```go -import * as lambda from "aws-cdk-lib/aws-lambda"; - -const lambda_function = new lambda.Function(this, "HelloHandler", { - runtime: lambda.Runtime.NODEJS_14_X, - code: lambda.Code.fromAsset("lambda"), - handler: "hello.handler", - tracing: lambda.Tracing.ACTIVE, -}); -``` - -### Nested Stacks - -Add the Datadog CDK Construct to each stack you wish to instrument with Datadog. In the example below, we initialize the Datadog CDK Construct and call `addLambdaFunctions()` in both the `RootStack` and `NestedStack`. - -```go -import { Datadog } from "datadog-cdk-constructs-v2"; -import * as cdk from "aws-cdk-lib"; -import { Construct } from "constructs"; - -class RootStack extends cdk.Stack { - constructor(scope: cdk.App, id: string, props?: cdk.StackProps) { - super(scope, id, props); - new NestedStack(this, "NestedStack"); - - const datadog = new Datadog(this, "Datadog", { - nodeLayerVersion: , - pythonLayerVersion: , - javaLayerVersion: , - dotnetLayerVersion: , - addLayers: , - forwarderArn: "", - flushMetricsToLogs: , - site: "", - apiKey: "{Datadog_API_Key}", - apiKeySecretArn: "{Secret_ARN_Datadog_API_Key}", - apiKmsKey: "{Encrypted_Datadog_API_Key}", - enableDatadogTracing: , - enableMergeXrayTraces: , - enableDatadogLogs: , - injectLogContext: - }); - datadog.addLambdaFunctions([]); - - } -} - -class NestedStack extends cdk.NestedStack { - constructor(scope: Construct, id: string, props?: cdk.NestedStackProps) { - super(scope, id, props); - - const datadog = new Datadog(this, "Datadog", { - nodeLayerVersion: , - pythonLayerVersion: , - javaLayerVersion: , - dotnetLayerVersion: , - addLayers: , - forwarderArn: "", - flushMetricsToLogs: , - site: "", - apiKey: "{Datadog_API_Key}", - apiKeySecretArn: "{Secret_ARN_Datadog_API_Key}", - apiKmsKey: "{Encrypted_Datadog_API_Key}", - enableDatadogTracing: , - enableMergeXrayTraces: , - enableDatadogLogs: , - injectLogContext: - }); - datadog.addLambdaFunctions([]); - - } -} -``` - -### Tags - -Add tags to your constructs. We recommend setting an `env` and `service` tag to tie Datadog telemetry together. For more information see [official AWS documentation](https://docs.aws.amazon.com/cdk/latest/guide/tagging.html) and [CDK documentation](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.Tags.html). - -## Automatically grant AWS secret read access to Lambda execution role - -**Only available in datadog-cdk-constructs-v2** - -To automatically grant your Lambda execution roles read access to a given secret, pass in `apiKeySecret` in place of `apiKeySecretArn` when initializing the Datadog construct. - -```go -const { Secret } = require('aws-cdk-lib/aws-secretsmanager'); - -const secret = Secret.fromSecretPartialArn(this, 'DatadogApiKeySecret', 'arn:aws:secretsmanager:us-west-1:123:secret:DATADOG_API_KEY'); - -const datadog = new Datadog(this, 'Datadog', { - ... - apiKeySecret: secret - ... -}); -``` - -When `addLambdaFunctions` is called, the Datadog CDK construct grants your Lambda execution roles read access to the given AWS secret. This is done through the [AWS ISecret's grantRead function](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_secretsmanager.ISecret.html#grantwbrreadgrantee-versionstages). - -## How it works - -The Datadog CDK construct takes in a list of lambda functions and installs the Datadog Lambda Library by attaching the Lambda Layers for [.NET](https://docs.datadoghq.com/serverless/aws_lambda/installation/dotnet), [Java](https://docs.datadoghq.com/serverless/installation/java/?tab=awscdk), [Node.js](https://github.com/DataDog/datadog-lambda-layer-js), and [Python](https://github.com/DataDog/datadog-lambda-layer-python) to your functions. It redirects to a replacement handler that initializes the Lambda Library without any required code changes. Additional configurations added to the Datadog CDK construct will also translate into their respective environment variables under each lambda function (if applicable / required). - -While Lambda function based log groups are handled by the `addLambdaFunctions` method automatically, the construct has an additional function `addForwarderToNonLambdaLogGroups` which subscribes the forwarder to any additional log groups of your choosing. - -## Resources to learn about CDK - -* [CDK TypeScript Workshop](https://cdkworkshop.com/20-typescript.html) -* [Video Introducing CDK by AWS with Demo](https://youtu.be/ZWCvNFUN-sU) -* [CDK Concepts](https://youtu.be/9As_ZIjUGmY) - -## Using Projen - -The Datadog CDK Construct Libraries use Projen to maintain project configuration files such as the `package.json`, `.gitignore`, `.npmignore`, etc. Most of the configuration files will be protected by Projen via read-only permissions. In order to change these files, edit the `.projenrc.js` file, then run `npx projen` to synthesize the new changes. Check out [Projen](https://github.com/projen/projen) for more details. - -## Opening Issues - -If you encounter a bug with this package, we want to hear about it. Before opening a new issue, search the existing issues to avoid duplicates. - -When opening an issue, include the Datadog CDK Construct version, Node version, and stack trace if available. In addition, include the steps to reproduce when appropriate. - -You can also open an issue for a feature request. - -## Contributing - -If you find an issue with this package and have a fix, please feel free to open a pull request following the [procedures](https://github.com/DataDog/datadog-cdk-constructs/blob/main/CONTRIBUTING.md). - -## Testing - -If you contribute to this package you can run the tests using `yarn test`. This package also includes a sample application for manual testing: - -1. Open a seperate terminal. -2. Run `yarn watch`, this will ensure the Typescript files in the `src` directory are compiled to Javascript in the `lib` directory. -3. Navigate to `src/sample`, here you can edit `index.ts` to test your contributions manually. -4. At the root directory, run `npx cdk --app lib/sample/index.js `, replacing `` with common CDK commands like `synth`, `diff`, or `deploy`. - -* Note, if you receive "... is not authorized to perform: ..." you may also need to authorize the commands with your AWS credentials. - -### Debug Logs - -To display the debug logs for this library, set the `DD_CONSTRUCT_DEBUG_LOGS` env var to `true` when running `cdk synth` (use `--quiet` to suppress generated template output). - -Example: -*Ensure you are at the root directory* - -``` -DD_CONSTRUCT_DEBUG_LOGS=true npx cdk --app lib/sample/index.js synth --quiet -``` - -## Community - -For product feedback and questions, join the `#serverless` channel in the [Datadog community on Slack](https://chat.datadoghq.com/). - -## License - -Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. - -This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021 Datadog, Inc. diff --git a/dist/go/ddcdkconstruct/Runtime.go b/dist/go/ddcdkconstruct/Runtime.go deleted file mode 100644 index df62dfb96..000000000 --- a/dist/go/ddcdkconstruct/Runtime.go +++ /dev/null @@ -1,7 +0,0 @@ -package ddcdkconstruct - - -type Runtime struct { - Name *string `field:"required" json:"name" yaml:"name"` -} - diff --git a/dist/go/ddcdkconstruct/RuntimeType.go b/dist/go/ddcdkconstruct/RuntimeType.go deleted file mode 100644 index 4322b5df6..000000000 --- a/dist/go/ddcdkconstruct/RuntimeType.go +++ /dev/null @@ -1,14 +0,0 @@ -package ddcdkconstruct - - -type RuntimeType string - -const ( - RuntimeType_DOTNET RuntimeType = "DOTNET" - RuntimeType_NODE RuntimeType = "NODE" - RuntimeType_PYTHON RuntimeType = "PYTHON" - RuntimeType_JAVA RuntimeType = "JAVA" - RuntimeType_CUSTOM RuntimeType = "CUSTOM" - RuntimeType_UNSUPPORTED RuntimeType = "UNSUPPORTED" -) - diff --git a/dist/go/ddcdkconstruct/TagKeys.go b/dist/go/ddcdkconstruct/TagKeys.go deleted file mode 100644 index f759373e2..000000000 --- a/dist/go/ddcdkconstruct/TagKeys.go +++ /dev/null @@ -1,12 +0,0 @@ -package ddcdkconstruct - - -type TagKeys string - -const ( - TagKeys_CDK TagKeys = "CDK" - TagKeys_ENV TagKeys = "ENV" - TagKeys_SERVICE TagKeys = "SERVICE" - TagKeys_VERSION TagKeys = "VERSION" -) - diff --git a/dist/go/ddcdkconstruct/Transport.go b/dist/go/ddcdkconstruct/Transport.go deleted file mode 100644 index 611424b73..000000000 --- a/dist/go/ddcdkconstruct/Transport.go +++ /dev/null @@ -1,180 +0,0 @@ -package ddcdkconstruct - -import ( - _jsii_ "github.com/aws/jsii-runtime-go/runtime" - _init_ "github.com/DataDog/datadog-cdk-constructs/dist/go/ddcdkconstruct/jsii" - - "github.com/aws/aws-cdk-go/awscdk/v2/awslambda" -) - -type Transport interface { - ApiKey() *string - SetApiKey(val *string) - ApiKeySecretArn() *string - SetApiKeySecretArn(val *string) - ApiKmsKey() *string - SetApiKmsKey(val *string) - ExtensionLayerVersion() *float64 - SetExtensionLayerVersion(val *float64) - FlushMetricsToLogs() *bool - SetFlushMetricsToLogs(val *bool) - Site() *string - SetSite(val *string) - ApplyEnvVars(lambdas *[]awslambda.Function) -} - -// The jsii proxy struct for Transport -type jsiiProxy_Transport struct { - _ byte // padding -} - -func (j *jsiiProxy_Transport) ApiKey() *string { - var returns *string - _jsii_.Get( - j, - "apiKey", - &returns, - ) - return returns -} - -func (j *jsiiProxy_Transport) ApiKeySecretArn() *string { - var returns *string - _jsii_.Get( - j, - "apiKeySecretArn", - &returns, - ) - return returns -} - -func (j *jsiiProxy_Transport) ApiKmsKey() *string { - var returns *string - _jsii_.Get( - j, - "apiKmsKey", - &returns, - ) - return returns -} - -func (j *jsiiProxy_Transport) ExtensionLayerVersion() *float64 { - var returns *float64 - _jsii_.Get( - j, - "extensionLayerVersion", - &returns, - ) - return returns -} - -func (j *jsiiProxy_Transport) FlushMetricsToLogs() *bool { - var returns *bool - _jsii_.Get( - j, - "flushMetricsToLogs", - &returns, - ) - return returns -} - -func (j *jsiiProxy_Transport) Site() *string { - var returns *string - _jsii_.Get( - j, - "site", - &returns, - ) - return returns -} - - -func NewTransport(flushMetricsToLogs *bool, site *string, apiKey *string, apiKeySecretArn *string, apiKmsKey *string, extensionLayerVersion *float64) Transport { - _init_.Initialize() - - j := jsiiProxy_Transport{} - - _jsii_.Create( - "datadog-cdk-constructs-v2.Transport", - []interface{}{flushMetricsToLogs, site, apiKey, apiKeySecretArn, apiKmsKey, extensionLayerVersion}, - &j, - ) - - return &j -} - -func NewTransport_Override(t Transport, flushMetricsToLogs *bool, site *string, apiKey *string, apiKeySecretArn *string, apiKmsKey *string, extensionLayerVersion *float64) { - _init_.Initialize() - - _jsii_.Create( - "datadog-cdk-constructs-v2.Transport", - []interface{}{flushMetricsToLogs, site, apiKey, apiKeySecretArn, apiKmsKey, extensionLayerVersion}, - t, - ) -} - -func (j *jsiiProxy_Transport)SetApiKey(val *string) { - _jsii_.Set( - j, - "apiKey", - val, - ) -} - -func (j *jsiiProxy_Transport)SetApiKeySecretArn(val *string) { - _jsii_.Set( - j, - "apiKeySecretArn", - val, - ) -} - -func (j *jsiiProxy_Transport)SetApiKmsKey(val *string) { - _jsii_.Set( - j, - "apiKmsKey", - val, - ) -} - -func (j *jsiiProxy_Transport)SetExtensionLayerVersion(val *float64) { - _jsii_.Set( - j, - "extensionLayerVersion", - val, - ) -} - -func (j *jsiiProxy_Transport)SetFlushMetricsToLogs(val *bool) { - if err := j.validateSetFlushMetricsToLogsParameters(val); err != nil { - panic(err) - } - _jsii_.Set( - j, - "flushMetricsToLogs", - val, - ) -} - -func (j *jsiiProxy_Transport)SetSite(val *string) { - if err := j.validateSetSiteParameters(val); err != nil { - panic(err) - } - _jsii_.Set( - j, - "site", - val, - ) -} - -func (t *jsiiProxy_Transport) ApplyEnvVars(lambdas *[]awslambda.Function) { - if err := t.validateApplyEnvVarsParameters(lambdas); err != nil { - panic(err) - } - _jsii_.InvokeVoid( - t, - "applyEnvVars", - []interface{}{lambdas}, - ) -} - diff --git a/dist/go/ddcdkconstruct/Transport__checks.go b/dist/go/ddcdkconstruct/Transport__checks.go deleted file mode 100644 index 801d9dfdf..000000000 --- a/dist/go/ddcdkconstruct/Transport__checks.go +++ /dev/null @@ -1,34 +0,0 @@ -//go:build !no_runtime_type_checking - -package ddcdkconstruct - -import ( - "fmt" - - "github.com/aws/aws-cdk-go/awscdk/v2/awslambda" -) - -func (t *jsiiProxy_Transport) validateApplyEnvVarsParameters(lambdas *[]awslambda.Function) error { - if lambdas == nil { - return fmt.Errorf("parameter lambdas is required, but nil was provided") - } - - return nil -} - -func (j *jsiiProxy_Transport) validateSetFlushMetricsToLogsParameters(val *bool) error { - if val == nil { - return fmt.Errorf("parameter val is required, but nil was provided") - } - - return nil -} - -func (j *jsiiProxy_Transport) validateSetSiteParameters(val *string) error { - if val == nil { - return fmt.Errorf("parameter val is required, but nil was provided") - } - - return nil -} - diff --git a/dist/go/ddcdkconstruct/Transport__no_checks.go b/dist/go/ddcdkconstruct/Transport__no_checks.go deleted file mode 100644 index a2d2d264f..000000000 --- a/dist/go/ddcdkconstruct/Transport__no_checks.go +++ /dev/null @@ -1,18 +0,0 @@ -//go:build no_runtime_type_checking - -package ddcdkconstruct - -// Building without runtime type checking enabled, so all the below just return nil - -func (t *jsiiProxy_Transport) validateApplyEnvVarsParameters(lambdas *[]awslambda.Function) error { - return nil -} - -func (j *jsiiProxy_Transport) validateSetFlushMetricsToLogsParameters(val *bool) error { - return nil -} - -func (j *jsiiProxy_Transport) validateSetSiteParameters(val *string) error { - return nil -} - diff --git a/dist/go/ddcdkconstruct/go.mod b/dist/go/ddcdkconstruct/go.mod deleted file mode 100644 index fcaf3d7f5..000000000 --- a/dist/go/ddcdkconstruct/go.mod +++ /dev/null @@ -1,12 +0,0 @@ -module github.com/DataDog/datadog-cdk-constructs/dist/go/ddcdkconstruct - -go 1.18 - -require ( - github.com/aws/jsii-runtime-go v1.98.0 - github.com/aws/aws-cdk-go/awscdk/v2 v2.134.0 - github.com/aws/constructs-go/constructs/v10 v10.0.5 - github.com/cdklabs/awscdk-asset-awscli-go/awscliv1/v2 v2.2.202 // indirect - github.com/cdklabs/awscdk-asset-kubectl-go/kubectlv20/v2 v2.1.2 // indirect - github.com/cdklabs/awscdk-asset-node-proxy-agent-go/nodeproxyagentv6/v2 v2.0.3 // indirect -) diff --git a/dist/go/ddcdkconstruct/internal/types.go b/dist/go/ddcdkconstruct/internal/types.go deleted file mode 100644 index 5b4e93388..000000000 --- a/dist/go/ddcdkconstruct/internal/types.go +++ /dev/null @@ -1,5 +0,0 @@ -package internal -import ( - "github.com/aws/constructs-go/constructs/v10" -) -type Type__constructsConstruct = constructs.Construct diff --git a/dist/go/ddcdkconstruct/jsii/jsii.go b/dist/go/ddcdkconstruct/jsii/jsii.go deleted file mode 100644 index 1b4779bd3..000000000 --- a/dist/go/ddcdkconstruct/jsii/jsii.go +++ /dev/null @@ -1,28 +0,0 @@ -// Package jsii contains the functionaility needed for jsii packages to -// initialize their dependencies and themselves. Users should never need to use this package -// directly. If you find you need to - please report a bug at -// https://github.com/aws/jsii/issues/new/choose -package jsii - -import ( - _ "embed" - - _jsii_ "github.com/aws/jsii-runtime-go/runtime" - - awscdk "github.com/aws/aws-cdk-go/awscdk/v2/jsii" - constructs "github.com/aws/constructs-go/constructs/v10/jsii" -) - -//go:embed datadog-cdk-constructs-v2-1.13.0.tgz -var tarball []byte - -// Initialize loads the necessary packages in the @jsii/kernel to support the enclosing module. -// The implementation is idempotent (and hence safe to be called over and over). -func Initialize() { - // Ensure all dependencies are initialized - awscdk.Initialize() - constructs.Initialize() - - // Load this library into the kernel - _jsii_.Load("datadog-cdk-constructs-v2", "1.13.0", tarball) -} diff --git a/dist/go/ddcdkconstruct/main.go b/dist/go/ddcdkconstruct/main.go deleted file mode 100644 index f032a0452..000000000 --- a/dist/go/ddcdkconstruct/main.go +++ /dev/null @@ -1,84 +0,0 @@ -// CDK Construct Library to automatically instrument Python and Node Lambda functions with Datadog using AWS CDK v2 -package ddcdkconstruct - -import ( - "reflect" - - _jsii_ "github.com/aws/jsii-runtime-go/runtime" -) - -func init() { - _jsii_.RegisterClass( - "datadog-cdk-constructs-v2.Datadog", - reflect.TypeOf((*Datadog)(nil)).Elem(), - []_jsii_.Member{ - _jsii_.MemberMethod{JsiiMethod: "addForwarderToNonLambdaLogGroups", GoMethod: "AddForwarderToNonLambdaLogGroups"}, - _jsii_.MemberMethod{JsiiMethod: "addGitCommitMetadata", GoMethod: "AddGitCommitMetadata"}, - _jsii_.MemberMethod{JsiiMethod: "addLambdaFunctions", GoMethod: "AddLambdaFunctions"}, - _jsii_.MemberProperty{JsiiProperty: "node", GoGetter: "Node"}, - _jsii_.MemberProperty{JsiiProperty: "props", GoGetter: "Props"}, - _jsii_.MemberProperty{JsiiProperty: "scope", GoGetter: "Scope"}, - _jsii_.MemberMethod{JsiiMethod: "toString", GoMethod: "ToString"}, - _jsii_.MemberProperty{JsiiProperty: "transport", GoGetter: "Transport"}, - }, - func() interface{} { - j := jsiiProxy_Datadog{} - _jsii_.InitJsiiProxy(&j.Type__constructsConstruct) - return &j - }, - ) - _jsii_.RegisterStruct( - "datadog-cdk-constructs-v2.DatadogProps", - reflect.TypeOf((*DatadogProps)(nil)).Elem(), - ) - _jsii_.RegisterStruct( - "datadog-cdk-constructs-v2.DatadogStrictProps", - reflect.TypeOf((*DatadogStrictProps)(nil)).Elem(), - ) - _jsii_.RegisterStruct( - "datadog-cdk-constructs-v2.Node", - reflect.TypeOf((*Node)(nil)).Elem(), - ) - _jsii_.RegisterStruct( - "datadog-cdk-constructs-v2.Runtime", - reflect.TypeOf((*Runtime)(nil)).Elem(), - ) - _jsii_.RegisterEnum( - "datadog-cdk-constructs-v2.RuntimeType", - reflect.TypeOf((*RuntimeType)(nil)).Elem(), - map[string]interface{}{ - "DOTNET": RuntimeType_DOTNET, - "NODE": RuntimeType_NODE, - "PYTHON": RuntimeType_PYTHON, - "JAVA": RuntimeType_JAVA, - "CUSTOM": RuntimeType_CUSTOM, - "UNSUPPORTED": RuntimeType_UNSUPPORTED, - }, - ) - _jsii_.RegisterEnum( - "datadog-cdk-constructs-v2.TagKeys", - reflect.TypeOf((*TagKeys)(nil)).Elem(), - map[string]interface{}{ - "CDK": TagKeys_CDK, - "ENV": TagKeys_ENV, - "SERVICE": TagKeys_SERVICE, - "VERSION": TagKeys_VERSION, - }, - ) - _jsii_.RegisterClass( - "datadog-cdk-constructs-v2.Transport", - reflect.TypeOf((*Transport)(nil)).Elem(), - []_jsii_.Member{ - _jsii_.MemberProperty{JsiiProperty: "apiKey", GoGetter: "ApiKey"}, - _jsii_.MemberProperty{JsiiProperty: "apiKeySecretArn", GoGetter: "ApiKeySecretArn"}, - _jsii_.MemberProperty{JsiiProperty: "apiKmsKey", GoGetter: "ApiKmsKey"}, - _jsii_.MemberMethod{JsiiMethod: "applyEnvVars", GoMethod: "ApplyEnvVars"}, - _jsii_.MemberProperty{JsiiProperty: "extensionLayerVersion", GoGetter: "ExtensionLayerVersion"}, - _jsii_.MemberProperty{JsiiProperty: "flushMetricsToLogs", GoGetter: "FlushMetricsToLogs"}, - _jsii_.MemberProperty{JsiiProperty: "site", GoGetter: "Site"}, - }, - func() interface{} { - return &jsiiProxy_Transport{} - }, - ) -} diff --git a/dist/go/ddcdkconstruct/version b/dist/go/ddcdkconstruct/version deleted file mode 100644 index feaae22ba..000000000 --- a/dist/go/ddcdkconstruct/version +++ /dev/null @@ -1 +0,0 @@ -1.13.0 diff --git a/package.json b/package.json index 97e546315..91a489d25 100644 --- a/package.json +++ b/package.json @@ -129,7 +129,7 @@ "module": "datadog_cdk_constructs_v2" }, "go": { - "moduleName": "github.com/DataDog/datadog-cdk-constructs/dist/go", + "moduleName": "github.com/DataDog/datadog-cdk-constructs-go", "packageName": "ddcdkconstruct" } },