///
import { aws_secretsmanager } from "aws-cdk-lib";
import type AWS from "aws-sdk";
import { Construct } from "constructs";
/**
* @returns `true` of {@link a} is a {@link Secret}, otherwise `false`.
*/
export declare function isSecret(a: any): a is Secret;
export interface SecretProps extends aws_secretsmanager.SecretProps {
}
/**
* Securely stores secret data such as credentials and API keys in an AWS Secret.
*
* @see https://aws.amazon.com/secrets-manager/
* @see {@link aws_secretsmanager.Secret}
*/
export declare abstract class Secret {
static readonly FunctionlessType = "Secret";
readonly FunctionlessType = "Secret";
readonly resource: aws_secretsmanager.ISecret;
/**
* Stores a new {@link SecretValue} in this {@link Secret}'s store.
*
* ```ts
* const secret = new Secret(scope, id, {});
*
* await secret.putSecretValue({
* SecretValue: {
* username: "sam"
* password: "my little pony"
* }
* });
* ```
*/
readonly putSecretValue: import("./integration").IntegrationCall<"AWS.SecretsManager.PutSecretValue", (input: PutSecretValueRequest) => Promise>;
/**
* Get the value of the Secret from the Secret Store.
*
* ```ts
* const { SecretValue } = await secret.getSecretValue();
* ```
*
* You can also specify the VersionId or VersionStage.
* ```ts
* const { SecretValue } = await secret.getSecretValue({
* VersionId: "",
* VersionStage: ""
* });
* ```
*/
readonly getSecretValue: import("./integration").IntegrationCall<"AWS.SecretsManager.GetSecretValue", (input?: Omit) => Promise>>;
constructor(resource: aws_secretsmanager.ISecret, props?: SecretProps);
constructor(scope: Construct, id: string, props?: SecretProps);
/**
* Provides the logic for deserializing the raw {@link AWS.SecretsManager.GetSecretValueResponse}
* into its {@link SecretValue} form.
* @param response the response of GetSecretValue API request.
*/
protected abstract deserialize(response: SerializedSecretValue): Promise;
/**
* Serialize a {@link SecretValue} into a SecretString or SecretBinary.
* @param secretValue the secret value to serialize
*/
protected abstract serialize(secretValue: SecretValue): SerializedSecretValue;
}
export declare type SerializedSecretValue = {
SecretString: AWS.SecretsManager.SecretStringType;
SecretBinary?: never;
} | {
SecretString?: never;
SecretBinary: AWS.SecretsManager.SecretBinaryType;
};
export interface GetSecretValueResponse extends AWS.SecretsManager.GetSecretValueResponse {
/**
* The {@link SecretValue} retrieved from the Store.
*/
SecretValue: SecretValue;
}
export interface PutSecretValueRequest extends Omit {
/**
* The {@link SecretValue} to write to the Store.
*/
SecretValue: SecretValue;
}
declare class BaseJsonSecret extends Secret {
protected serialize(secretValue: SecretValue): {
SecretString: string;
};
protected deserialize(response: SerializedSecretValue): Promise;
}
/**
* Interface for a {@link JsonSecret}.
*
* Produced by {@link JsonSecret.from}.
*/
export interface IJsonSecret extends BaseJsonSecret {
}
/**
* Securely stores a JSON-encoded {@link SecretValue}.
*
* ```ts
* interface UserPass {
* username: string;
* password: string;
* }
* const secret = new JsonSecret(scope, "id");
*
* new Function(scope, "foo", async () => {
* const response = await secret.getSecretValue();
*
* // secret is automatically deserialized from JSON
* const { username, password } = response.SecretValue!;
*
* // secret is automatically serialized to JSON
* await secret.putSecretValue({
* SecretValue: {
* username: "sam",
* password: "password123"
* }
* });
* });
* ```
*/
export declare class JsonSecret extends BaseJsonSecret {
/**
* Import a {@link JsonSecret} from an existing {@link aws_secretsmanager.ISecret}.
*
* ```ts
* import { aws_secretsmanager } from "aws-cdk-lib";
*
* const secret: aws_secretsmanager.ISecret;
*
* const jsonSecret = JsonSecret.from(secret);
* ```
*
* @param secret
* @returns
*/
static from(secret: aws_secretsmanager.ISecret): IJsonSecret;
constructor(scope: Construct, id: string, props?: SecretProps);
}
declare class BaseTextSecret extends Secret {
protected serialize(secretValue: string): {
SecretString: string;
};
protected deserialize(secretValue: SerializedSecretValue): Promise;
}
/**
* Interface for a {@link TextSecret}.
*
* Produced by {@link TextSecret.from}.
*/
export interface ITextSecret extends BaseTextSecret {
}
/**
* Securely stores a string-encoded secret.
*
* ```ts
* const secret = new TextSecret(scope, "id");
*
* new Function(scope, "foo", async () => {
* const text = await secret.getSecretValue();
*
* await secret.putSecretValue({
* SecretValue: "secret key 123"
* });
* });
* ```
*/
export declare class TextSecret extends BaseTextSecret implements ITextSecret {
/**
* Import a {@link TextSecret} from an existing {@link aws_secretsmanager.ISecret}.
*
* ```ts
* import { aws_secretsmanager } from "aws-cdk-lib";
*
* const secret: aws_secretsmanager.ISecret;
*
* const textSecret = TextSecret.from(secret);
* ```
*
* @param secret
* @returns
*/
static from(secret: aws_secretsmanager.ISecret): ITextSecret;
constructor(scope: Construct, id: string, props?: SecretProps);
}
declare class BaseBinarySecret extends Secret {
protected serialize(secretValue: Buffer): SerializedSecretValue;
protected deserialize(secretValue: SerializedSecretValue): Promise;
}
/**
* Interface for a {@link BinarySecret}.
*
* Produced by {@link BinarySecret.from}.
*/
export interface IBinarySecret extends BaseBinarySecret {
}
/**
* Securely stores a binary-encoded secret.
*
* ```ts
* const secret = new TextSecret(scope, "id");
*
* new Function(scope, "foo", async () => {
* const bytes = await secret.getSecretValue();
*
* await secret.putSecretValue({
* SecretValue: Buffer.from("secret key 123", "utf8")
* });
* });
* ```
*/
export declare class BinarySecret extends BaseBinarySecret {
/**
* Import a {@link BinarySecret} from an existing {@link aws_secretsmanager.ISecret}.
*
* ```ts
* import { aws_secretsmanager } from "aws-cdk-lib";
*
* const secret: aws_secretsmanager.ISecret;
*
* const binarySecret = BinarySecret.from(secret);
* ```
*
* @param secret
* @returns
*/
static from(secret: aws_secretsmanager.ISecret): IBinarySecret;
constructor(scope: Construct, id: string, props?: SecretProps);
}
export {};
//# sourceMappingURL=secret.d.ts.map