/// <summary> /// Creates a secret using an existing KMS key from the existing KMS id /// </summary> /// <param name="secretName"></param> /// <param name="encryptionKeyId"></param> /// <param name="charsToExclude"></param> /// <param name="passwordLength"></param> /// <returns></returns> public ISecret Create(string secretName, string encryptionKeyId, string charsToExclude = "^{}^{}\"@/;-+=&\\/", int passwordLength = 16, IKeyProps encryptionKeyProperties = null) { if (string.IsNullOrEmpty(encryptionKeyId)) { throw new ArgumentException("The provided encryptionKeyId can not be null"); } var key = AwsCdkKmsHandler.Locate(encryptionKeyId, null) ?? new Key(Scope, encryptionKeyId, encryptionKeyProperties); return(Create(secretName, key, charsToExclude, passwordLength)); }
public AwsCdkSecretHandler(Construct scope, string applicationName, string environmentName, AwsCdkKmsHandler awsCdkKmsHandler, string region, string accountId) : base(scope, applicationName, environmentName) { if (string.IsNullOrEmpty(region) || string.IsNullOrEmpty(accountId)) { throw new ArgumentException("The accountId or region can not be null for the secrethandler constructor"); } TagHandler = new TagHandler(); AwsCdkKmsHandler = awsCdkKmsHandler; Region = region; AccountId = accountId; }
public AwsCdkHandler(Construct scope, string id, string applicationName, string environmentName, IStackProps props = null) : base(scope, id, props) { if (string.IsNullOrEmpty(applicationName) || string.IsNullOrEmpty(environmentName)) { throw new ArgumentException("The application name or the environment name can not be null"); } ApplicationName = applicationName; EnvironmentName = environmentName; AwsCdkKmsHandler = new AwsCdkKmsHandler(this, ApplicationName, EnvironmentName); EnvironmentProperties = props?.Env; AwsCdkVpcHandler = new AwsCdkVpcHandler(this, ApplicationName, EnvironmentName); AwsCdkS3Handler = new AwsCdkS3Handler(this, ApplicationName, EnvironmentName); AwsSecurityGroupHandler = new AwsSecurityGroupHandler(this, ApplicationName, EnvironmentName, AwsCdkVpcHandler); AwsCdkSecretHandler = new AwsCdkSecretHandler(this, ApplicationName, EnvironmentName, AwsCdkKmsHandler, EnvironmentProperties?.Region, EnvironmentProperties?.Account); AwsCdkDatabaseHandler = new AwsCdkDatabaseHandler(this, ApplicationName, EnvironmentName, AwsSecurityGroupHandler, AwsCdkVpcHandler, AwsCdkSecretHandler); }