public void EnsureStackExists() { if (_hasCreatedStack) return; _awsConfiguration = new AwsConfiguration { AssumeRoleTrustDocument = Roles.Path("code-deploy-trust.json"), IamRolePolicyDocument = Roles.Path("code-deploy-policy.json"), Bucket = "aws-deployment-tools-tests", RoleName = "CodeDeployRole", AwsEndpoint = TestConfiguration.AwsEndpoint, Credentials = new TestSuiteCredentials() }; _iamClient = new AmazonIdentityManagementServiceClient( new AmazonIdentityManagementServiceConfig { RegionEndpoint = _awsConfiguration.AwsEndpoint, ProxyHost = _awsConfiguration.ProxyHost, ProxyPort = _awsConfiguration.ProxyPort }); DeletePreviousTestStack(); _deployer = new Deployer(_awsConfiguration); _stack = _deployer.CreateStack(new StackTemplate { StackName = StackName, TemplatePath = CloudFormationTemplates.Path("example-windows-vpc-autoscaling-group.template") }); _hasCreatedStack = true; }
public void EnsureStackExists() { if (_hasCreatedStack) return; _awsConfiguration = new AwsConfiguration { AssumeRoleTrustDocument = Roles.Path("code-deploy-trust.json"), IamRolePolicyDocument = Roles.Path("code-deploy-policy.json"), Bucket = "aws-deployment-tools-tests", RoleName = "CodeDeployRole", AwsEndpoint = TestConfiguration.AwsEndpoint, Credentials = new TestSuiteCredentials() }; _deployer = new Deployer(_awsConfiguration); DeletePreviousTestStack(); _stack = _deployer.CreateStack(new StackTemplate { StackName = StackName, TemplatePath = CloudFormationTemplates.Path("example-windows-vpc.template") }); _hasCreatedStack = true; }
public void SetUp() { var awsEndpoint = TestConfiguration.AwsEndpoint; var credentials = new TestSuiteCredentials(); _s3Client = new AmazonS3Client(awsEndpoint); _iamClient = new AmazonIdentityManagementServiceClient(awsEndpoint); _awsConfiguration = new AwsConfiguration { IamRolePolicyDocument = Roles.Path("s3-policy-new-bucket.json"), AssumeRoleTrustDocument = Roles.Path("code-deploy-trust.json"), Bucket = "s3-push-test", RoleName = "SomeNewRole", AwsEndpoint = awsEndpoint, Credentials = credentials }; _deployer = new Deployer(_awsConfiguration); _localBuildDirectory = ExampleRevisions.Directory("HelloWorld-1.2.3"); _applicationSetName = "HelloWorld"; _version = "1.1.1"; DeleteRolesAndPolicies(); }
public Deployer(AwsConfiguration awsConfiguration) { _awsEndpoint = awsConfiguration.AwsEndpoint; _bucket = awsConfiguration.Bucket; _assumeRoleTrustDocument = awsConfiguration.AssumeRoleTrustDocument; _iamRolePolicyDocument = awsConfiguration.IamRolePolicyDocument; AWSCredentials credentials; if (isArn(awsConfiguration.RoleName)) { var securityTokenServiceClient = new AmazonSecurityTokenServiceClient(awsConfiguration.AwsEndpoint); var assumeRoleResult = securityTokenServiceClient.AssumeRole(new AssumeRoleRequest { RoleArn = awsConfiguration.RoleName, DurationSeconds = 3600, RoleSessionName = "Net2User", ExternalId = Guid.NewGuid().ToString() }); Credentials stsCredentials = assumeRoleResult.Credentials; SessionAWSCredentials sessionCredentials = new SessionAWSCredentials(stsCredentials.AccessKeyId, stsCredentials.SecretAccessKey, stsCredentials.SessionToken); credentials = sessionCredentials; _role = new AssumedRole(assumeRoleResult.AssumedRoleUser); } else { credentials = awsConfiguration.Credentials ?? new EnvironmentAWSCredentials(); } _codeDeployClient = new AmazonCodeDeployClient( credentials, new AmazonCodeDeployConfig { RegionEndpoint = awsConfiguration.AwsEndpoint, ProxyHost = awsConfiguration.ProxyHost, ProxyPort = awsConfiguration.ProxyPort }); _cloudFormationClient = new AmazonCloudFormationClient( credentials, new AmazonCloudFormationConfig { RegionEndpoint = awsConfiguration.AwsEndpoint, ProxyHost = awsConfiguration.ProxyHost, ProxyPort = awsConfiguration.ProxyPort }); _s3Client = new AmazonS3Client( credentials, new AmazonS3Config { RegionEndpoint = awsConfiguration.AwsEndpoint, ProxyHost = awsConfiguration.ProxyHost, ProxyPort = awsConfiguration.ProxyPort }); _iamClient = new AmazonIdentityManagementServiceClient( credentials, new AmazonIdentityManagementServiceConfig { RegionEndpoint = awsConfiguration.AwsEndpoint, ProxyHost = awsConfiguration.ProxyHost, ProxyPort = awsConfiguration.ProxyPort }); _autoScalingClient = new AmazonAutoScalingClient( credentials, new AmazonAutoScalingConfig { RegionEndpoint = awsConfiguration.AwsEndpoint, ProxyHost = awsConfiguration.ProxyHost, ProxyPort = awsConfiguration.ProxyPort }); }
private void SetUp(string stackName) { _awsConfiguration = new AwsConfiguration { AwsEndpoint = TestConfiguration.AwsEndpoint, Credentials = new TestSuiteCredentials(), Bucket = "aws-deployment-tools-tests" }; _cloudFormationClient = new AmazonCloudFormationClient( new AmazonCloudFormationConfig { RegionEndpoint = _awsConfiguration.AwsEndpoint } ); _ec2Client = new AmazonEC2Client(new AmazonEC2Config { RegionEndpoint = _awsConfiguration.AwsEndpoint }); DeleteTestStack(stackName); }
public void SetUp() { _awsConfiguration = new AwsConfiguration { AwsEndpoint = TestConfiguration.AwsEndpoint, Credentials = new TestSuiteCredentials() }; _iamClient = new AmazonIdentityManagementServiceClient( new AmazonIdentityManagementServiceConfig { RegionEndpoint = _awsConfiguration.AwsEndpoint, ProxyHost = _awsConfiguration.ProxyHost, ProxyPort = _awsConfiguration.ProxyPort }); var user = _iamClient.CreateUser(new CreateUserRequest { UserName = _userName }).User; _roleToAssume = _iamClient.CreateRoleToAssume(user); _awsConfiguration.RoleName = _roleToAssume.Arn; _s3Client = new AmazonS3Client(new AmazonS3Config { RegionEndpoint = _awsConfiguration.AwsEndpoint }); DeletePreviousTestStack(); }