Skip to content
v2.274.0

TrustStore L2 construct ​

A new Trust Store.

Example ​

ts
import * as acm from 'aws-cdk-lib/aws-certificatemanager';

declare const certificate: acm.Certificate;
declare const lb: elbv2.ApplicationLoadBalancer;
declare const bucket: s3.Bucket;

const trustStore = new elbv2.TrustStore(this, 'Store', {
  bucket,
  key: 'rootCA_cert.pem',
});

lb.addListener('Listener', {
  port: 443,
  protocol: elbv2.ApplicationProtocol.HTTPS,
  certificates: [certificate],
  // mTLS settings
  mutualAuthentication: {
    advertiseTrustStoreCaNames: true,
    ignoreClientCertificateExpiry: false,
    mutualAuthenticationMode: elbv2.MutualAuthenticationMode.VERIFY,
    trustStore,
  },
  defaultAction: elbv2.ListenerAction.fixedResponse(200,
    { contentType: 'text/plain', messageBody: 'Success mTLS' }),
});
python
import aws_cdk.aws_certificatemanager as acm

# certificate: acm.Certificate
# lb: elbv2.ApplicationLoadBalancer
# bucket: s3.Bucket


trust_store = elbv2.TrustStore(self, "Store",
    bucket=bucket,
    key="rootCA_cert.pem"
)

lb.add_listener("Listener",
    port=443,
    protocol=elbv2.ApplicationProtocol.HTTPS,
    certificates=[certificate],
    # mTLS settings
    mutual_authentication=elbv2.MutualAuthentication(
        advertise_trust_store_ca_names=True,
        ignore_client_certificate_expiry=False,
        mutual_authentication_mode=elbv2.MutualAuthenticationMode.VERIFY,
        trust_store=trust_store
    ),
    default_action=elbv2.ListenerAction.fixed_response(200, content_type="text/plain", message_body="Success mTLS")
)
java
import software.amazon.awscdk.services.certificatemanager.*;

Certificate certificate;
ApplicationLoadBalancer lb;
Bucket bucket;


TrustStore trustStore = TrustStore.Builder.create(this, "Store")
        .bucket(bucket)
        .key("rootCA_cert.pem")
        .build();

lb.addListener("Listener", BaseApplicationListenerProps.builder()
        .port(443)
        .protocol(ApplicationProtocol.HTTPS)
        .certificates(List.of(certificate))
        // mTLS settings
        .mutualAuthentication(MutualAuthentication.builder()
                .advertiseTrustStoreCaNames(true)
                .ignoreClientCertificateExpiry(false)
                .mutualAuthenticationMode(MutualAuthenticationMode.VERIFY)
                .trustStore(trustStore)
                .build())
        .defaultAction(ListenerAction.fixedResponse(200, FixedResponseOptions.builder().contentType("text/plain").messageBody("Success mTLS").build()))
        .build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.AWS.CertificateManager;

Certificate certificate;
ApplicationLoadBalancer lb;
Bucket bucket;


var trustStore = new TrustStore(this, "Store", new TrustStoreProps {
    Bucket = bucket,
    Key = "rootCA_cert.pem"
});

lb.AddListener("Listener", new BaseApplicationListenerProps {
    Port = 443,
    Protocol = ApplicationProtocol.HTTPS,
    Certificates = new [] { certificate },
    // mTLS settings
    MutualAuthentication = new MutualAuthentication {
        AdvertiseTrustStoreCaNames = true,
        IgnoreClientCertificateExpiry = false,
        MutualAuthenticationMode = MutualAuthenticationMode.VERIFY,
        TrustStore = trustStore
    },
    DefaultAction = ListenerAction.FixedResponse(200, new FixedResponseOptions { ContentType = "text/plain", MessageBody = "Success mTLS" })
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import acm "github.com/aws/aws-cdk-go/awscdk"

var certificate Certificate
var lb ApplicationLoadBalancer
var bucket Bucket


trustStore := elbv2.NewTrustStore(this, jsii.String("Store"), &TrustStoreProps{
	Bucket: Bucket,
	Key: jsii.String("rootCA_cert.pem"),
})

lb.AddListener(jsii.String("Listener"), &BaseApplicationListenerProps{
	Port: jsii.Number(443),
	Protocol: elbv2.ApplicationProtocol_HTTPS,
	Certificates: []IListenerCertificate{
		certificate,
	},
	// mTLS settings
	MutualAuthentication: &MutualAuthentication{
		AdvertiseTrustStoreCaNames: jsii.Boolean(true),
		IgnoreClientCertificateExpiry: jsii.Boolean(false),
		MutualAuthenticationMode: elbv2.MutualAuthenticationMode_VERIFY,
		TrustStore: *TrustStore,
	},
	DefaultAction: elbv2.ListenerAction_FixedResponse(jsii.Number(200), &FixedResponseOptions{
		ContentType: jsii.String("text/plain"),
		MessageBody: jsii.String("Success mTLS"),
	}),
})

Initializer ​

ts
new TrustStore(scope: Construct, id: string, props: TrustStoreProps)
python
TrustStore(scope: Construct, id: str, props: TrustStoreProps)
java
new TrustStore(Construct scope, String id, TrustStoreProps props)
csharp
new TrustStore(Construct scope, string id, TrustStoreProps props)
go
NewTrustStore(Scope Construct, Id *string, Props TrustStoreProps)

Construct Props ​

bucketIBucketRefbucketIBucketRefbucketIBucketRefBucketIBucketRefBucketIBucketRefrequired#
The bucket that the trust store is hosted in.
keystringkeystrkeyStringKeystringKey*stringrequired#
The key in S3 to look at for the trust store.
trustStoreNameoptionalstringtrust_store_nameoptionalstrtrustStoreNameoptionalStringTrustStoreNameoptionalstringTrustStoreNameoptional*string#
The name of the trust store.

Default: Auto generated

versionoptionalstringversionoptionalstrversionoptionalStringVersionoptionalstringVersionoptional*string#
The version of the S3 object that contains your truststore.

Default: latest version

To specify a version, you must have versioning enabled for the S3 bucket.

Properties ​

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.

nodeNodenodeNodenodeNodeNodeNodeNodeNode#
The tree node.
numberOfCaCertificatesnumbernumber_of_ca_certificatesint | floatnumberOfCaCertificatesNumberNumberOfCaCertificatesdoubleNumberOfCaCertificates*float64#
The number of CA certificates in the trust store.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringstatic#
Uniquely identifies this class.
stackStackstackStackstackStackStackStackStackStack#
The stack in which this resource is defined.
statusstringstatusstrstatusStringStatusstringStatus*string#
The status of the trust store.
trustStoreArnstringtrust_store_arnstrtrustStoreArnStringTrustStoreArnstringTrustStoreArn*string#
The ARN of the trust store.
trustStoreNamestringtrust_store_namestrtrustStoreNameStringTrustStoreNamestringTrustStoreName*string#
The name of the trust store.
trustStoreRefTrustStoreReferencetrust_store_refTrustStoreReferencetrustStoreRefTrustStoreReferenceTrustStoreRefTrustStoreReferenceTrustStoreRefTrustStoreReference#
A reference to this trust store.

Methods ​

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

fromTrustStoreArn(scope: Construct, id: string, trustStoreArn: string): ITrustStore@staticmethod def from_trust_store_arn(scope: Construct, id: str, trust_store_arn: str) -> ITrustStorepublic static ITrustStore fromTrustStoreArn(Construct scope, String id, String trustStoreArn)public static ITrustStore FromTrustStoreArn(Construct scope, string id, string trustStoreArn)func FromTrustStoreArn(Scope Construct, Id *string, TrustStoreArn *string) ITrustStorestatic#
Import from ARN.
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.