Skip to content
v2.274.0

Connection L2 construct ​

An AWS Glue connection to a data source.

Example ​

ts
import * as cdk from 'aws-cdk-lib';
import * as iam from 'aws-cdk-lib/aws-iam';
declare const stack: cdk.Stack;
declare const role: iam.IRole;
declare const script: glue.Code;
new glue.PySparkEtlJob(stack, 'PySparkETLJob', {
  jobName: 'PySparkETLJobCustomName',
  description: 'This is a description',
  role,
  script,
  glueVersion: glue.GlueVersion.V6_0,
  continuousLogging: { enabled: false },
  workerConfiguration: {
    workerType: glue.WorkerType.G_2X,
    numberOfWorkers: 2,
  },
  maxConcurrentRuns: 100,
  timeout: cdk.Duration.hours(2),
  connections: [glue.Connection.fromConnectionName(stack, 'Connection', 'connectionName')],
  securityConfiguration: glue.SecurityConfiguration.fromSecurityConfigurationName(stack, 'SecurityConfig', 'securityConfigName'),
  tags: {
    FirstTagName: 'FirstTagValue',
    SecondTagName: 'SecondTagValue',
    XTagName: 'XTagValue',
  },
  maxRetries: 2,
});
python
import aws_cdk as cdk
import aws_cdk.aws_iam as iam
# stack: cdk.Stack
# role: iam.IRole
# script: glue.Code

glue.PySparkEtlJob(stack, "PySparkETLJob",
    job_name="PySparkETLJobCustomName",
    description="This is a description",
    role=role,
    script=script,
    glue_version=glue.GlueVersion.V6_0,
    continuous_logging=glue.ContinuousLoggingProps(enabled=False),
    worker_configuration=glue.WorkerConfiguration(
        worker_type=glue.WorkerType.G_2X,
        number_of_workers=2
    ),
    max_concurrent_runs=100,
    timeout=cdk.Duration.hours(2),
    connections=[glue.Connection.from_connection_name(stack, "Connection", "connectionName")],
    security_configuration=glue.SecurityConfiguration.from_security_configuration_name(stack, "SecurityConfig", "securityConfigName"),
    tags={
        "FirstTagName": "FirstTagValue",
        "SecondTagName": "SecondTagValue",
        "XTagName": "XTagValue"
    },
    max_retries=2
)
java
import software.amazon.awscdk.*;
import software.amazon.awscdk.services.iam.*;
Stack stack;
IRole role;
Code script;

PySparkEtlJob.Builder.create(stack, "PySparkETLJob")
        .jobName("PySparkETLJobCustomName")
        .description("This is a description")
        .role(role)
        .script(script)
        .glueVersion(GlueVersion.V6_0)
        .continuousLogging(ContinuousLoggingProps.builder().enabled(false).build())
        .workerConfiguration(WorkerConfiguration.builder()
                .workerType(WorkerType.G_2X)
                .numberOfWorkers(2)
                .build())
        .maxConcurrentRuns(100)
        .timeout(Duration.hours(2))
        .connections(List.of(Connection.fromConnectionName(stack, "Connection", "connectionName")))
        .securityConfiguration(SecurityConfiguration.fromSecurityConfigurationName(stack, "SecurityConfig", "securityConfigName"))
        .tags(Map.of(
                "FirstTagName", "FirstTagValue",
                "SecondTagName", "SecondTagValue",
                "XTagName", "XTagValue"))
        .maxRetries(2)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK;
using Amazon.CDK.AWS.IAM;
Stack stack;
IRole role;
Code script;

new PySparkEtlJob(stack, "PySparkETLJob", new PySparkEtlJobProps {
    JobName = "PySparkETLJobCustomName",
    Description = "This is a description",
    Role = role,
    Script = script,
    GlueVersion = GlueVersion.V6_0,
    ContinuousLogging = new ContinuousLoggingProps { Enabled = false },
    WorkerConfiguration = new WorkerConfiguration {
        WorkerType = WorkerType.G_2X,
        NumberOfWorkers = 2
    },
    MaxConcurrentRuns = 100,
    Timeout = Duration.Hours(2),
    Connections = new [] { Connection.FromConnectionName(stack, "Connection", "connectionName") },
    SecurityConfiguration = SecurityConfiguration.FromSecurityConfigurationName(stack, "SecurityConfig", "securityConfigName"),
    Tags = new Dictionary<string, string> {
        { "FirstTagName", "FirstTagValue" },
        { "SecondTagName", "SecondTagValue" },
        { "XTagName", "XTagValue" }
    },
    MaxRetries = 2
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import cdk "github.com/aws/aws-cdk-go/awscdk"
import iam "github.com/aws/aws-cdk-go/awscdk"
var stack Stack
var role IRole
var script Code

glue.NewPySparkEtlJob(stack, jsii.String("PySparkETLJob"), &PySparkEtlJobProps{
	JobName: jsii.String("PySparkETLJobCustomName"),
	Description: jsii.String("This is a description"),
	Role: Role,
	Script: Script,
	GlueVersion: glue.GlueVersion_V6_0,
	ContinuousLogging: &ContinuousLoggingProps{
		Enabled: jsii.Boolean(false),
	},
	WorkerConfiguration: &WorkerConfiguration{
		WorkerType: glue.WorkerType_G_2X,
		NumberOfWorkers: jsii.Number(2),
	},
	MaxConcurrentRuns: jsii.Number(100),
	Timeout: cdk.Duration_Hours(jsii.Number(2)),
	Connections: []IConnection{
		glue.Connection_FromConnectionName(stack, jsii.String("Connection"), jsii.String("connectionName")),
	},
	SecurityConfiguration: glue.SecurityConfiguration_FromSecurityConfigurationName(stack, jsii.String("SecurityConfig"), jsii.String("securityConfigName")),
	Tags: map[string]*string{
		"FirstTagName": jsii.String("FirstTagValue"),
		"SecondTagName": jsii.String("SecondTagValue"),
		"XTagName": jsii.String("XTagValue"),
	},
	MaxRetries: jsii.Number(2),
})

Initializer ​

ts
new Connection(scope: Construct, id: string, props: ConnectionProps)
python
Connection(scope: Construct, id: str, props: ConnectionProps)
java
new Connection(Construct scope, String id, ConnectionProps props)
csharp
new Connection(Construct scope, string id, ConnectionProps props)
go
NewConnection(Scope Construct, Id *string, Props ConnectionProps)

Construct Props ​

connectionNameoptionalstringconnection_nameoptionalstrconnectionNameoptionalStringConnectionNameoptionalstringConnectionNameoptional*string#
The name of the connection.

Default: cloudformation generated name

descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string#
The description of the connection.

Default: no description

matchCriteriaoptionalstring[]match_criteriaoptionaltyping.List[str]matchCriteriaoptionalList<String>MatchCriteriaoptionalstring[]MatchCriteriaoptional*[]*string#
A list of criteria that can be used in selecting this connection.

Default: no match criteria

This is useful for filtering the results of https://awscli.amazonaws.com/v2/documentation/api/latest/reference/glue/get-connections.html

networkoptionalConnectionNetworknetworkoptionalConnectionNetworknetworkoptionalConnectionNetworkNetworkoptionalConnectionNetworkNetworkoptionalConnectionNetwork#
The VPC network placement for this connection, so it can reach resources inside a VPC. See more at https://docs.aws.amazon.com/glue/latest/dg/start-connecting.html.

Default: no VPC network placement

Build it with ConnectionNetwork.subnet(subnet) to pin a specific subnet, or ConnectionNetwork.vpc(vpc, vpcSubnets?) to let the CDK select one.

propertiesoptional{ [key: string]: string }propertiesoptionaltyping.Mapping[str, str]propertiesoptionalMap<String, String>PropertiesoptionalIDictionary<string, string>Propertiesoptional*map[string]*string#
Key-Value pairs that define parameters for the connection.

Default: empty properties

secretoptionalISecretRefsecretoptionalISecretRefsecretoptionalISecretRefSecretoptionalISecretRefSecretoptionalISecretRef#
A reference to a Secrets Manager secret holding the credentials for this connection.

Default: no secret; any credentials must be supplied via properties

notes

The secret is referenced through the connection's SECRET_ID property, so Glue reads the credentials at runtime and the secret value never appears in the synthesized template. Prefer this over placing credentials directly in properties. Accepts any secretsmanager.ISecret.

securityGroupsoptionalISecurityGroup[]security_groupsoptionaltyping.List[ISecurityGroup]securityGroupsoptionalList<ISecurityGroup>SecurityGroupsoptionalISecurityGroup[]SecurityGroupsoptional*[]ISecurityGroup#
The list of security groups needed to successfully make this connection e.g. to successfully connect to VPC.

Default: no security group

The type of the connection.

Properties ​

connectionArnstringconnection_arnstrconnectionArnStringConnectionArnstringConnectionArn*stringrequired#
The ARN of the connection.
connectionNamestringconnection_namestrconnectionNameStringConnectionNamestringConnectionName*stringrequired#
The name of the connection.
The environment this resource belongs to.
notes

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#
Uniquely identifies this class.
stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this resource is defined.

Methods ​

addProperty(key: string, value: string): voiddef add_property(self, key: str, value: str) -> Nonepublic void addProperty(String key, String value)public void AddProperty(string key, string value)func AddProperty(Key *string, Value *string)#
Add additional connection parameters.
2 parameters

Parameters

  • keykeykeykeyKey — parameter key.
  • valuevaluevaluevalueValue — parameter value.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Override the cross-stack reference strength for this resource.
notes · 1 parameter

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

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).

fromConnectionArn(scope: Construct, id: string, connectionArn: string): IConnection@staticmethod def from_connection_arn(scope: Construct, id: str, connection_arn: str) -> IConnectionpublic static IConnection fromConnectionArn(Construct scope, String id, String connectionArn)public static IConnection FromConnectionArn(Construct scope, string id, string connectionArn)func FromConnectionArn(Scope Construct, Id *string, ConnectionArn *string) IConnectionstatic#
Creates a Connection construct that represents an external connection.
3 parameters

Parameters

  • scopescopescopescopeScope — The scope creating construct (usually this).
  • ididididId — The construct's id.
  • connectionArnconnection_arnconnectionArnconnectionArnConnectionArn — arn of external connection.
fromConnectionName(scope: Construct, id: string, connectionName: string): IConnection@staticmethod def from_connection_name(scope: Construct, id: str, connection_name: str) -> IConnectionpublic static IConnection fromConnectionName(Construct scope, String id, String connectionName)public static IConnection FromConnectionName(Construct scope, string id, string connectionName)func FromConnectionName(Scope Construct, Id *string, ConnectionName *string) IConnectionstatic#
Creates a Connection construct that represents an external connection.
3 parameters

Parameters

  • scopescopescopescopeScope — The scope creating construct (usually this).
  • ididididId — The construct's id.
  • connectionNameconnection_nameconnectionNameconnectionNameConnectionName — name of external connection.
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

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.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#
Check whether the given construct is a Resource.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.