Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        private void BasicDatabaseInfra(IVpc vpc, string secretName, string securityId, string securityGroupId,
                                        SubnetType subnetType, string defaultSubnetDomainSeparator, string subnets, out ISecurityGroup securityGroup,
                                        out ISecret secret, out ISubnetSelection subnetSelection)
        {
            if (vpc == null)
            {
                throw new ArgumentException($"The VPC provided to create the database is not valid");
            }

            securityGroup = AwsSecurityGroupHandler.Locate(securityId, securityGroupId);

            if (securityGroup == null)
            {
                throw new ArgumentException($"The Security group id {securityGroupId} provided to create the database is not valid");
            }

            secret          = AwsCdkSecretHandler.Create(secretName);
            subnetSelection = AwsCdkVpcHandler.GetVpcSubnetSelection(vpc, subnets, defaultSubnetDomainSeparator, subnetType);
        }
Exemplo n.º 3
0
 public AwsSecurityGroupHandler(Construct scope, string applicationName, string environmentName, AwsCdkVpcHandler awsCdkVpcHandler) : base(scope, applicationName, environmentName)
 {
     AwsCdkVpcHandler = awsCdkVpcHandler;
 }
Exemplo n.º 4
0
 public IVpc LocateVpc(string identification, string vpcId, bool isDefault = true)
 {
     return(AwsCdkVpcHandler.Locate(identification, vpcId, isDefault));
 }
Exemplo n.º 5
0
 public IVpc AddVpc(string cidr, double?maxAzs, DefaultInstanceTenancy defaultInstanceTenancy, string vpcIdentification = null, bool enableDnsSupport = true, bool enableDnsHostnames = true, List <ISubnetConfiguration> subnetConfigurations = null, Dictionary <string, string> tags = null)
 {
     return(AwsCdkVpcHandler.Create(string.IsNullOrEmpty(vpcIdentification) ? $"{ApplicationName}{EnvironmentName}vpc" : vpcIdentification, cidr, maxAzs, defaultInstanceTenancy, enableDnsSupport, enableDnsHostnames, subnetConfigurations, tags));
 }