Experimental
@aws-cdk/aws-apprunner-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
Secret Class
A secret environment variable.
Example
ts
import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager';
import * as ssm from 'aws-cdk-lib/aws-ssm';
declare const stack: Stack;
const secret = new secretsmanager.Secret(stack, 'Secret');
const parameter = ssm.StringParameter.fromSecureStringParameterAttributes(stack, 'Parameter', {
parameterName: '/name',
version: 1,
});
const service = new apprunner.Service(stack, 'Service', {
source: apprunner.Source.fromEcrPublic({
imageConfiguration: {
port: 8000,
environmentSecrets: {
SECRET: apprunner.Secret.fromSecretsManager(secret),
PARAMETER: apprunner.Secret.fromSsmParameter(parameter),
SECRET_ID: apprunner.Secret.fromSecretsManagerVersion(secret, { versionId: 'version-id' }),
SECRET_STAGE: apprunner.Secret.fromSecretsManagerVersion(secret, { versionStage: 'version-stage' }),
},
},
imageIdentifier: 'public.ecr.aws/aws-containers/hello-app-runner:latest',
})
});
service.addSecret('LATER_SECRET', apprunner.Secret.fromSecretsManager(secret, 'field'));
Initializer
ts
new Secret()
python
Secret()
java
new Secret()
csharp
new Secret()
go
NewSecret()
Properties
Methods
fromSecretsManager(secret: ISecret, field?: string): Secret // chainable@staticmethod def from_secrets_manager(secret: ISecret, field: typing.Optional[str] = None) -> Secretpublic static Secret fromSecretsManager(ISecret secret, String field)public static Secret FromSecretsManager(ISecret secret, string? field = null)func FromSecretsManager(Secret ISecret, Field *string) Secretstatic#Creates a environment variable value from a secret stored in AWS Secrets Manager.
2 parameters
Parameters
secretsecretsecretsecretSecret— the secret stored in AWS Secrets Manager.fieldfieldfieldfieldField— the name of the field with the value that you want to set as the environment variable value.
fromSecretsManagerVersion(secret: ISecret, versionInfo: SecretVersionInfo, field?: string): Secret // chainable@staticmethod def from_secrets_manager_version(secret: ISecret, version_info: SecretVersionInfo, field: typing.Optional[str] = None) -> Secretpublic static Secret fromSecretsManagerVersion(ISecret secret, SecretVersionInfo versionInfo, String field)public static Secret FromSecretsManagerVersion(ISecret secret, SecretVersionInfo versionInfo, string? field = null)func FromSecretsManagerVersion(Secret ISecret, VersionInfo SecretVersionInfo, Field *string) Secretstatic#Creates a environment variable value from a secret stored in AWS Secrets Manager.
3 parameters
Parameters
secretsecretsecretsecretSecret— the secret stored in AWS Secrets Manager.versionInfoversion_infoversionInfoversionInfoVersionInfo— the version information to reference the secret.fieldfieldfieldfieldField— the name of the field with the value that you want to set as the environment variable value.
fromSsmParameter(parameter: IParameter): Secret // chainable@staticmethod def from_ssm_parameter(parameter: IParameter) -> Secretpublic static Secret fromSsmParameter(IParameter parameter)public static Secret FromSsmParameter(IParameter parameter)func FromSsmParameter(Parameter IParameter) Secretstatic#Creates an environment variable value from a parameter stored in AWS Systems Manager Parameter Store.
grantRead(grantee: IGrantable): Grantdef grant_read(self, grantee: IGrantable) -> Grantpublic Grant grantRead(IGrantable grantee)public Grant GrantRead(IGrantable grantee)func GrantRead(Grantee IGrantable) Grant#Grants reading the secret to a principal.
[disable-awslint:no-grants]