package experimental import ( _init_ "github.com/aws/aws-cdk-go/awscdk/v2/jsii" _jsii_ "github.com/aws/jsii-runtime-go/runtime" "github.com/aws/aws-cdk-go/awscdk/v2" "github.com/aws/aws-cdk-go/awscdk/v2/awscloudfront/experimental/internal" "github.com/aws/aws-cdk-go/awscdk/v2/awscloudwatch" "github.com/aws/aws-cdk-go/awscdk/v2/awsec2" "github.com/aws/aws-cdk-go/awscdk/v2/awsiam" "github.com/aws/aws-cdk-go/awscdk/v2/awslambda" "github.com/aws/constructs-go/constructs/v10" ) // A Lambda@Edge function. // // Convenience resource for requesting a Lambda function in the 'us-east-1' region for use with Lambda@Edge. // Implements several restrictions enforced by Lambda@Edge. // // Note that this construct requires that the 'us-east-1' region has been bootstrapped. // See https://docs.aws.amazon.com/cdk/latest/guide/bootstrapping.html or 'cdk bootstrap --help' for options. // // Example: // var myBucket bucket // // A Lambda@Edge function added to default behavior of a Distribution // // and triggered on every request // myFunc := experimental.NewEdgeFunction(this, jsii.String("MyFunction"), &EdgeFunctionProps{ // Runtime: lambda.Runtime_NODEJS_14_X(), // Handler: jsii.String("index.handler"), // Code: lambda.Code_FromAsset(path.join(__dirname, jsii.String("lambda-handler"))), // }) // cloudfront.NewDistribution(this, jsii.String("myDist"), &DistributionProps{ // DefaultBehavior: &BehaviorOptions{ // Origin: origins.NewS3Origin(myBucket), // EdgeLambdas: []edgeLambda{ // &edgeLambda{ // FunctionVersion: myFunc.currentVersion, // EventType: cloudfront.LambdaEdgeEventType_VIEWER_REQUEST, // }, // }, // }, // }) // type EdgeFunction interface { awscdk.Resource awslambda.IVersion // The system architectures compatible with this lambda function. Architecture() awslambda.Architecture // Not supported. // // Connections are only applicable to VPC-enabled functions. Connections() awsec2.Connections // Convenience method to make `EdgeFunction` conform to the same interface as `Function`. CurrentVersion() awslambda.IVersion // The ARN of the version for Lambda@Edge. EdgeArn() *string // The environment this resource belongs to. // // For resources that are created and managed by the CDK // (generally, those created by creating new class instances like Role, Bucket, etc.), // this is always the same as the environment of the stack they belong to; // however, for imported resources // (those obtained from static methods like fromRoleArn, fromBucketName, etc.), // that might be different than the stack they were imported into. Env() *awscdk.ResourceEnvironment // The ARN of the function. FunctionArn() *string // The name of the function. FunctionName() *string // The principal to grant permissions to. GrantPrincipal() awsiam.IPrincipal // Whether or not this Lambda function was bound to a VPC. // // If this is is `false`, trying to access the `connections` object will fail. IsBoundToVpc() *bool // The underlying AWS Lambda function. Lambda() awslambda.IFunction // The `$LATEST` version of this function. // // Note that this is reference to a non-specific AWS Lambda version, which // means the function this version refers to can return different results in // different invocations. // // To obtain a reference to an explicit version which references the current // function configuration, use `lambdaFunction.currentVersion` instead. LatestVersion() awslambda.IVersion // The tree node. Node() constructs.Node // The construct node where permissions are attached. PermissionsNode() constructs.Node // Returns a string-encoded token that resolves to the physical name that should be passed to the CloudFormation resource. // // This value will resolve to one of the following: // - a concrete value (e.g. `"my-awesome-bucket"`) // - `undefined`, when a name should be generated by CloudFormation // - a concrete name generated automatically during synthesis, in // cross-environment scenarios. PhysicalName() *string // The ARN(s) to put into the resource field of the generated IAM policy for grantInvoke(). // // This property is for cdk modules to consume only. You should not need to use this property. // Instead, use grantInvoke() directly. ResourceArnsForGrantInvoke() *[]*string // The IAM role associated with this function. Role() awsiam.IRole // The stack in which this resource is defined. Stack() awscdk.Stack // The most recently deployed version of this function. Version() *string // Defines an alias for this version. AddAlias(aliasName *string, options *awslambda.AliasOptions) awslambda.Alias // Adds an event source to this function. AddEventSource(source awslambda.IEventSource) // Adds an event source that maps to this AWS Lambda function. AddEventSourceMapping(id *string, options *awslambda.EventSourceMappingOptions) awslambda.EventSourceMapping // Adds a url to this lambda function. AddFunctionUrl(options *awslambda.FunctionUrlOptions) awslambda.FunctionUrl // Adds a permission to the Lambda resource policy. AddPermission(id *string, permission *awslambda.Permission) // Adds a statement to the IAM role assumed by the instance. AddToRolePolicy(statement awsiam.PolicyStatement) // Apply the given removal policy to this resource. // // The Removal Policy controls what happens to this resource when it stops // being managed by CloudFormation, either because you've removed it from the // CDK application or because you've made a change that requires the resource // to be replaced. // // The resource can be deleted (`RemovalPolicy.DESTROY`), or left in your AWS // account for data recovery and cleanup later (`RemovalPolicy.RETAIN`). ApplyRemovalPolicy(policy awscdk.RemovalPolicy) // Configures options for asynchronous invocation. ConfigureAsyncInvoke(options *awslambda.EventInvokeConfigOptions) GeneratePhysicalName() *string // Returns an environment-sensitive token that should be used for the resource's "ARN" attribute (e.g. `bucket.bucketArn`). // // Normally, this token will resolve to `arnAttr`, but if the resource is // referenced across environments, `arnComponents` will be used to synthesize // a concrete ARN with the resource's physical name. Make sure to reference // `this.physicalName` in `arnComponents`. GetResourceArnAttribute(arnAttr *string, arnComponents *awscdk.ArnComponents) *string // Returns an environment-sensitive token that should be used for the resource's "name" attribute (e.g. `bucket.bucketName`). // // Normally, this token will resolve to `nameAttr`, but if the resource is // referenced across environments, it will be resolved to `this.physicalName`, // which will be a concrete name. GetResourceNameAttribute(nameAttr *string) *string // Grant the given identity permissions to invoke this Lambda. GrantInvoke(identity awsiam.IGrantable) awsiam.Grant // Grant the given identity permissions to invoke this Lambda Function URL. GrantInvokeUrl(identity awsiam.IGrantable) awsiam.Grant // Return the given named metric for this Lambda Return the given named metric for this Function. Metric(metricName *string, props *awscloudwatch.MetricOptions) awscloudwatch.Metric // Metric for the Duration of this Lambda How long execution of this Lambda takes. // // Average over 5 minutes. MetricDuration(props *awscloudwatch.MetricOptions) awscloudwatch.Metric // How many invocations of this Lambda fail. // // Sum over 5 minutes. MetricErrors(props *awscloudwatch.MetricOptions) awscloudwatch.Metric // Metric for the number of invocations of this Lambda How often this Lambda is invoked. // // Sum over 5 minutes. MetricInvocations(props *awscloudwatch.MetricOptions) awscloudwatch.Metric // Metric for the number of throttled invocations of this Lambda How often this Lambda is throttled. // // Sum over 5 minutes. MetricThrottles(props *awscloudwatch.MetricOptions) awscloudwatch.Metric // Returns a string representation of this construct. ToString() *string } // The jsii proxy struct for EdgeFunction type jsiiProxy_EdgeFunction struct { internal.Type__awscdkResource internal.Type__awslambdaIVersion } func (j *jsiiProxy_EdgeFunction) Architecture() awslambda.Architecture { var returns awslambda.Architecture _jsii_.Get( j, "architecture", &returns, ) return returns } func (j *jsiiProxy_EdgeFunction) Connections() awsec2.Connections { var returns awsec2.Connections _jsii_.Get( j, "connections", &returns, ) return returns } func (j *jsiiProxy_EdgeFunction) CurrentVersion() awslambda.IVersion { var returns awslambda.IVersion _jsii_.Get( j, "currentVersion", &returns, ) return returns } func (j *jsiiProxy_EdgeFunction) EdgeArn() *string { var returns *string _jsii_.Get( j, "edgeArn", &returns, ) return returns } func (j *jsiiProxy_EdgeFunction) Env() *awscdk.ResourceEnvironment { var returns *awscdk.ResourceEnvironment _jsii_.Get( j, "env", &returns, ) return returns } func (j *jsiiProxy_EdgeFunction) FunctionArn() *string { var returns *string _jsii_.Get( j, "functionArn", &returns, ) return returns } func (j *jsiiProxy_EdgeFunction) FunctionName() *string { var returns *string _jsii_.Get( j, "functionName", &returns, ) return returns } func (j *jsiiProxy_EdgeFunction) GrantPrincipal() awsiam.IPrincipal { var returns awsiam.IPrincipal _jsii_.Get( j, "grantPrincipal", &returns, ) return returns } func (j *jsiiProxy_EdgeFunction) IsBoundToVpc() *bool { var returns *bool _jsii_.Get( j, "isBoundToVpc", &returns, ) return returns } func (j *jsiiProxy_EdgeFunction) Lambda() awslambda.IFunction { var returns awslambda.IFunction _jsii_.Get( j, "lambda", &returns, ) return returns } func (j *jsiiProxy_EdgeFunction) LatestVersion() awslambda.IVersion { var returns awslambda.IVersion _jsii_.Get( j, "latestVersion", &returns, ) return returns } func (j *jsiiProxy_EdgeFunction) Node() constructs.Node { var returns constructs.Node _jsii_.Get( j, "node", &returns, ) return returns } func (j *jsiiProxy_EdgeFunction) PermissionsNode() constructs.Node { var returns constructs.Node _jsii_.Get( j, "permissionsNode", &returns, ) return returns } func (j *jsiiProxy_EdgeFunction) PhysicalName() *string { var returns *string _jsii_.Get( j, "physicalName", &returns, ) return returns } func (j *jsiiProxy_EdgeFunction) ResourceArnsForGrantInvoke() *[]*string { var returns *[]*string _jsii_.Get( j, "resourceArnsForGrantInvoke", &returns, ) return returns } func (j *jsiiProxy_EdgeFunction) Role() awsiam.IRole { var returns awsiam.IRole _jsii_.Get( j, "role", &returns, ) return returns } func (j *jsiiProxy_EdgeFunction) Stack() awscdk.Stack { var returns awscdk.Stack _jsii_.Get( j, "stack", &returns, ) return returns } func (j *jsiiProxy_EdgeFunction) Version() *string { var returns *string _jsii_.Get( j, "version", &returns, ) return returns } func NewEdgeFunction(scope constructs.Construct, id *string, props *EdgeFunctionProps) EdgeFunction { _init_.Initialize() if err := validateNewEdgeFunctionParameters(scope, id, props); err != nil { panic(err) } j := jsiiProxy_EdgeFunction{} _jsii_.Create( "aws-cdk-lib.aws_cloudfront.experimental.EdgeFunction", []interface{}{scope, id, props}, &j, ) return &j } func NewEdgeFunction_Override(e EdgeFunction, scope constructs.Construct, id *string, props *EdgeFunctionProps) { _init_.Initialize() _jsii_.Create( "aws-cdk-lib.aws_cloudfront.experimental.EdgeFunction", []interface{}{scope, id, props}, e, ) } // Checks if `x` is a construct. // // Use this method instead of `instanceof` to properly detect `Construct` // instances, even when the construct library is symlinked. // // Explanation: in JavaScript, multiple copies of the `constructs` library on // disk are seen as independent, completely different libraries. As a // consequence, the class `Construct` in each copy of the `constructs` library // is seen as a different class, and an instance of one class will not test as // `instanceof` the other class. `npm install` will not create installations // like this, but users may manually symlink construct libraries together or // use a monorepo tool: in those cases, multiple copies of the `constructs` // library can be accidentally installed, and `instanceof` will behave // unpredictably. It is safest to avoid using `instanceof`, and using // this type-testing method instead. // // Returns: true if `x` is an object created from a class which extends `Construct`. func EdgeFunction_IsConstruct(x interface{}) *bool { _init_.Initialize() if err := validateEdgeFunction_IsConstructParameters(x); err != nil { panic(err) } var returns *bool _jsii_.StaticInvoke( "aws-cdk-lib.aws_cloudfront.experimental.EdgeFunction", "isConstruct", []interface{}{x}, &returns, ) return returns } // Returns true if the construct was created by CDK, and false otherwise. func EdgeFunction_IsOwnedResource(construct constructs.IConstruct) *bool { _init_.Initialize() if err := validateEdgeFunction_IsOwnedResourceParameters(construct); err != nil { panic(err) } var returns *bool _jsii_.StaticInvoke( "aws-cdk-lib.aws_cloudfront.experimental.EdgeFunction", "isOwnedResource", []interface{}{construct}, &returns, ) return returns } // Check whether the given construct is a Resource. func EdgeFunction_IsResource(construct constructs.IConstruct) *bool { _init_.Initialize() if err := validateEdgeFunction_IsResourceParameters(construct); err != nil { panic(err) } var returns *bool _jsii_.StaticInvoke( "aws-cdk-lib.aws_cloudfront.experimental.EdgeFunction", "isResource", []interface{}{construct}, &returns, ) return returns } func (e *jsiiProxy_EdgeFunction) AddAlias(aliasName *string, options *awslambda.AliasOptions) awslambda.Alias { if err := e.validateAddAliasParameters(aliasName, options); err != nil { panic(err) } var returns awslambda.Alias _jsii_.Invoke( e, "addAlias", []interface{}{aliasName, options}, &returns, ) return returns } func (e *jsiiProxy_EdgeFunction) AddEventSource(source awslambda.IEventSource) { if err := e.validateAddEventSourceParameters(source); err != nil { panic(err) } _jsii_.InvokeVoid( e, "addEventSource", []interface{}{source}, ) } func (e *jsiiProxy_EdgeFunction) AddEventSourceMapping(id *string, options *awslambda.EventSourceMappingOptions) awslambda.EventSourceMapping { if err := e.validateAddEventSourceMappingParameters(id, options); err != nil { panic(err) } var returns awslambda.EventSourceMapping _jsii_.Invoke( e, "addEventSourceMapping", []interface{}{id, options}, &returns, ) return returns } func (e *jsiiProxy_EdgeFunction) AddFunctionUrl(options *awslambda.FunctionUrlOptions) awslambda.FunctionUrl { if err := e.validateAddFunctionUrlParameters(options); err != nil { panic(err) } var returns awslambda.FunctionUrl _jsii_.Invoke( e, "addFunctionUrl", []interface{}{options}, &returns, ) return returns } func (e *jsiiProxy_EdgeFunction) AddPermission(id *string, permission *awslambda.Permission) { if err := e.validateAddPermissionParameters(id, permission); err != nil { panic(err) } _jsii_.InvokeVoid( e, "addPermission", []interface{}{id, permission}, ) } func (e *jsiiProxy_EdgeFunction) AddToRolePolicy(statement awsiam.PolicyStatement) { if err := e.validateAddToRolePolicyParameters(statement); err != nil { panic(err) } _jsii_.InvokeVoid( e, "addToRolePolicy", []interface{}{statement}, ) } func (e *jsiiProxy_EdgeFunction) ApplyRemovalPolicy(policy awscdk.RemovalPolicy) { if err := e.validateApplyRemovalPolicyParameters(policy); err != nil { panic(err) } _jsii_.InvokeVoid( e, "applyRemovalPolicy", []interface{}{policy}, ) } func (e *jsiiProxy_EdgeFunction) ConfigureAsyncInvoke(options *awslambda.EventInvokeConfigOptions) { if err := e.validateConfigureAsyncInvokeParameters(options); err != nil { panic(err) } _jsii_.InvokeVoid( e, "configureAsyncInvoke", []interface{}{options}, ) } func (e *jsiiProxy_EdgeFunction) GeneratePhysicalName() *string { var returns *string _jsii_.Invoke( e, "generatePhysicalName", nil, // no parameters &returns, ) return returns } func (e *jsiiProxy_EdgeFunction) GetResourceArnAttribute(arnAttr *string, arnComponents *awscdk.ArnComponents) *string { if err := e.validateGetResourceArnAttributeParameters(arnAttr, arnComponents); err != nil { panic(err) } var returns *string _jsii_.Invoke( e, "getResourceArnAttribute", []interface{}{arnAttr, arnComponents}, &returns, ) return returns } func (e *jsiiProxy_EdgeFunction) GetResourceNameAttribute(nameAttr *string) *string { if err := e.validateGetResourceNameAttributeParameters(nameAttr); err != nil { panic(err) } var returns *string _jsii_.Invoke( e, "getResourceNameAttribute", []interface{}{nameAttr}, &returns, ) return returns } func (e *jsiiProxy_EdgeFunction) GrantInvoke(identity awsiam.IGrantable) awsiam.Grant { if err := e.validateGrantInvokeParameters(identity); err != nil { panic(err) } var returns awsiam.Grant _jsii_.Invoke( e, "grantInvoke", []interface{}{identity}, &returns, ) return returns } func (e *jsiiProxy_EdgeFunction) GrantInvokeUrl(identity awsiam.IGrantable) awsiam.Grant { if err := e.validateGrantInvokeUrlParameters(identity); err != nil { panic(err) } var returns awsiam.Grant _jsii_.Invoke( e, "grantInvokeUrl", []interface{}{identity}, &returns, ) return returns } func (e *jsiiProxy_EdgeFunction) Metric(metricName *string, props *awscloudwatch.MetricOptions) awscloudwatch.Metric { if err := e.validateMetricParameters(metricName, props); err != nil { panic(err) } var returns awscloudwatch.Metric _jsii_.Invoke( e, "metric", []interface{}{metricName, props}, &returns, ) return returns } func (e *jsiiProxy_EdgeFunction) MetricDuration(props *awscloudwatch.MetricOptions) awscloudwatch.Metric { if err := e.validateMetricDurationParameters(props); err != nil { panic(err) } var returns awscloudwatch.Metric _jsii_.Invoke( e, "metricDuration", []interface{}{props}, &returns, ) return returns } func (e *jsiiProxy_EdgeFunction) MetricErrors(props *awscloudwatch.MetricOptions) awscloudwatch.Metric { if err := e.validateMetricErrorsParameters(props); err != nil { panic(err) } var returns awscloudwatch.Metric _jsii_.Invoke( e, "metricErrors", []interface{}{props}, &returns, ) return returns } func (e *jsiiProxy_EdgeFunction) MetricInvocations(props *awscloudwatch.MetricOptions) awscloudwatch.Metric { if err := e.validateMetricInvocationsParameters(props); err != nil { panic(err) } var returns awscloudwatch.Metric _jsii_.Invoke( e, "metricInvocations", []interface{}{props}, &returns, ) return returns } func (e *jsiiProxy_EdgeFunction) MetricThrottles(props *awscloudwatch.MetricOptions) awscloudwatch.Metric { if err := e.validateMetricThrottlesParameters(props); err != nil { panic(err) } var returns awscloudwatch.Metric _jsii_.Invoke( e, "metricThrottles", []interface{}{props}, &returns, ) return returns } func (e *jsiiProxy_EdgeFunction) ToString() *string { var returns *string _jsii_.Invoke( e, "toString", nil, // no parameters &returns, ) return returns }