public void SetUp()
        {
            AWSCredentials credentials = AmbientCredentials.GetCredentials();

            Ec2Client = AWSClientFactory.CreateAmazonEC2Client(credentials);
            Service   = new SecurityGroupService(Ec2Client);
        }
        public void SetUp()
        {
            AWSCredentials credentials = AmbientCredentials.GetCredentials();

            S3Client       = AWSClientFactory.CreateAmazonS3Client(credentials);
            StorageService = new StorageService(S3Client, new S3PathParser());
        }
        public void SetUp()
        {
            var credentials = AmbientCredentials.GetCredentials();

            IamClient = AWSClientFactory.CreateAmazonIdentityManagementServiceClient(credentials);

            IdentityService = new IdentityService(IamClient, new ArnParser());
        }
Exemple #4
0
        public void SetUp()
        {
            AWSCredentials credentials = AmbientCredentials.GetCredentials();

            Ec2Client            = AWSClientFactory.CreateAmazonEC2Client(credentials);
            SecurityGroupService = new SecurityGroupService(Ec2Client);

            Creator = new DefaultSecurityGroupCreator(SecurityGroupService)
            {
                SecurityGroupName = _testSecurityGroupName
            };
        }
Exemple #5
0
        public IContainer GetContainer()
        {
            if (BootstrapData == null)
            {
                BootstrapData = BootstrapApplication();
            }

            var builder = new ContainerBuilder();

            builder.RegisterWebPortal();

            // You'll need to have an AWS profile configured in one of two ways:
            //   1) Ambient environment http://docs.aws.amazon.com/AWSSdkDocsNET/latest/DeveloperGuide/net-dg-config-creds.html
            //   2) EC2 IAM role
            //
            // The profile will need:
            //   * EC2 access to describe the tags of the instance StackIt is running on
            //   * S3 access to the bucket where the bootstrap config lives
            //   * KMS access to the master key that's used for encrypting other AWS profiles
            builder.Register(context => AmbientCredentials.GetCredentials()).As <AWSCredentials>();

            builder.Register(context =>
            {
                var kmsClient      = new AmazonKeyManagementServiceClient(context.Resolve <AWSCredentials>());
                var masterKeyAlias = context.Resolve <IStackItConfiguration>().CloudOptions.MasterKeyAlias;
                return(new EnvelopeCryptoProvider(kmsClient, string.Format("alias/{0}", masterKeyAlias)));
            }).As <ICryptoProvider>();

            // At this point, the application is configured to use values supplied by app.config
            // However, if we're running on EC2 and bootstrap data was provided,
            // we need to overwrite some infrastructure-level registrations
            if (BootstrapData != null)
            {
                builder.RegisterType <BootstrapDatabaseConfiguration>().As <IDatabaseConfiguration>()
                .WithParameter("connectionString", BootstrapData.ApplicationDatabaseConnectionString);

                builder.RegisterType <BootstrapCrowdConfiguration>().As <ICrowdConfiguration>()
                .WithParameter("url", BootstrapData.CrowdUrl)
                .WithParameter("applicationName", BootstrapData.CrowdUsername)
                .WithParameter("apiPassword", BootstrapData.CrowdPassword);

                builder.RegisterType <BootstrapHangfireConfiguration>().As <IHangfireConfiguration>()
                .WithParameter("connectionString", BootstrapData.HangfireDatabaseConnectionString);
            }

            builder.Register(_ => EventBus.Instance).SingleInstance();
            builder.RegisterHubWithLifetimeScope <EventBusHub>();

            return(builder.Build());
        }
Exemple #6
0
        public void ConfigureTemplateExpiry()
        {
            // Set up the lifecycle rules for the bucket where we store Cloud Formation templates
            var cloudOptions   = new CloudOptions();
            var credentials    = AmbientCredentials.GetCredentials();
            var s3Client       = AWSClientFactory.CreateAmazonS3Client(credentials);
            var storageService = new StorageService(s3Client, new S3PathParser());

            storageService.CreateExpirationRule(
                cloudOptions.ConfigurationTemplateBucket,
                Conventions.ConfigurationTemplateBucketPrefix,
                7,
                "Cloud Formation Template Cleanup"
                );
        }
Exemple #7
0
        private static BootstrapData BootstrapApplication()
        {
            // If we're not on EC2, then we'll not even try bootstrapping the application.
            if (!IsEc2)
            {
                return(null);
            }

            // Uses ambient AWS credentials, probably from an IAM role.
            // This should be exactly the same as just creating the clients without passing the credentials.
            // It is left explicit to guarantee the same algorithm is used to get credentials here as it is
            // in Startup.Autofac.cs.
            AWSCredentials credentials = AmbientCredentials.GetCredentials();
            IAmazonEC2     ec2Client   = AWSClientFactory.CreateAmazonEC2Client(credentials);
            IAmazonS3      s3Client    = AWSClientFactory.CreateAmazonS3Client(credentials);

            var instanceService = new InstanceService(ec2Client);
            var storageService  = new StorageService(s3Client, new S3PathParser());
            var metadataService = new MetadataService();

            var bootstrapper = new ApplicationBootstrapper(instanceService, storageService, metadataService);

            return(bootstrapper.BootstrapApplication());
        }