in packages/components/secrets/src/secret-component.ts [22:67]
constructor(blueprint: Blueprint, secret: SecretDefinition) {
super(blueprint);
this.name = secret.name;
this.description = secret.description;
this.reference = '${Secrets.' + this.name + '}';
const nameRegex = /^[a-zA-Z0-9]+(?:[-_][a-zA-Z0-9]+)*$/;
if (this.name) {
if (!nameRegex.test(this.name)) {
blueprint.throwSynthesisError({
name: BlueprintSynthesisErrorTypes.ValidationError,
message: 'Secret name must contain only alphanumeric characters and the characters _- and cannot start or end with special characters.',
});
}
if (this.name.length < 3) {
blueprint.throwSynthesisError({
name: BlueprintSynthesisErrorTypes.ValidationError,
message: 'Secret name must have a minimum of 3 characters.',
});
}
if (this.name.length > 255) {
blueprint.throwSynthesisError({
name: BlueprintSynthesisErrorTypes.ValidationError,
message: 'Secret name must have a maximum of 255 characters.',
});
}
if (this.description && this.description.length > 1000) {
blueprint.throwSynthesisError({
name: BlueprintSynthesisErrorTypes.ValidationError,
message: 'Secret description must have a maxmimum of 1000 characters.',
});
}
const shortName = this.name.slice(0, 5);
new YamlFile(blueprint, `secrets/${shortName}-${getHashedEntropy(5, shortName)}.yaml`, {
readonly: false,
marker: false,
obj: { name: this.name, description: this.description },
});
}
}