use of com.amazonaws.services.cloudformation.model.Parameter in project aws-cf-templates by widdix.
the class TestRDSPostgres method testWithSecret.
@Test
public void testWithSecret() {
final Context context = new Context();
final String vpcStackName = "vpc-2azs-" + this.random8String();
final String clientStackName = "client-" + this.random8String();
final String secretStackName = "secret-" + this.random8String();
final String stackName = "rds-postgres-" + this.random8String();
try {
this.createStack(context, vpcStackName, "vpc/vpc-2azs.yaml");
try {
this.createStack(context, clientStackName, "state/client-sg.yaml", new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName));
try {
this.createStack(context, secretStackName, "state/secretsmanager-dbsecret.yaml");
try {
this.createStack(context, stackName, "state/rds-postgres.yaml", new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName), new Parameter().withParameterKey("ParentClientStack").withParameterValue(clientStackName), new Parameter().withParameterKey("ParentSecretStack").withParameterValue(secretStackName), new Parameter().withParameterKey("DBName").withParameterValue("db1"));
// TODO how can we check if this stack works? start a bastion host and try to connect?
} finally {
this.deleteStack(context, stackName);
}
} finally {
this.deleteStack(context, secretStackName);
}
} finally {
this.deleteStack(context, clientStackName);
}
} finally {
this.deleteStack(context, vpcStackName);
}
}
use of com.amazonaws.services.cloudformation.model.Parameter in project aws-cf-templates by widdix.
the class TestAL2MutablePublic method testWithIAMUserSSHAccess.
@Test
public void testWithIAMUserSSHAccess() throws Exception {
final Context context = new Context();
final String vpcStackName = "vpc-2azs-" + this.random8String();
final String stackName = "al2-mutable-public-" + this.random8String();
final String classB = "10";
final String userName = "user-" + this.random8String();
try {
final User user = this.createUser(userName);
try {
this.createStack(context, vpcStackName, "vpc/vpc-2azs.yaml", new Parameter().withParameterKey("ClassB").withParameterValue(classB));
try {
this.createStack(context, stackName, "ec2/al2-mutable-public.yaml", new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName), new Parameter().withParameterKey("IAMUserSSHAccess").withParameterValue("true"));
final String host = this.getStackOutputValue(stackName, "PublicIPAddress");
this.probeSSH(context, host, user);
} finally {
this.deleteStack(context, stackName);
}
} finally {
this.deleteStack(context, vpcStackName);
}
} finally {
this.deleteUser(context, userName);
}
}
use of com.amazonaws.services.cloudformation.model.Parameter in project aws-cf-templates by widdix.
the class TestAL2MutablePublic method test.
@Test
public void test() {
final Context context = new Context();
final String vpcStackName = "vpc-2azs-" + this.random8String();
final String stackName = "al2-mutable-public-" + this.random8String();
final String classB = "10";
final String keyName = "key-" + this.random8String();
try {
final KeyPair key = this.createKey(keyName);
try {
this.createStack(context, vpcStackName, "vpc/vpc-2azs.yaml", new Parameter().withParameterKey("ClassB").withParameterValue(classB));
try {
this.createStack(context, stackName, "ec2/al2-mutable-public.yaml", new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName), new Parameter().withParameterKey("KeyName").withParameterValue(keyName), new Parameter().withParameterKey("BackupRetentionPeriod").withParameterValue("0"));
final String host = this.getStackOutputValue(stackName, "PublicIPAddress");
this.probeSSH(context, host, key);
} finally {
this.deleteStack(context, stackName);
}
} finally {
this.deleteStack(context, vpcStackName);
}
} finally {
this.deleteKey(context, keyName);
}
}
use of com.amazonaws.services.cloudformation.model.Parameter in project aws-cf-templates by widdix.
the class TestECSService method testClusterAlbPathPattern.
@Test
public void testClusterAlbPathPattern() {
final Context context = new Context();
final String vpcStackName = "vpc-2azs-" + this.random8String();
final String clusterStackName = "ecs-cluster-" + this.random8String();
final String stackName = "ecs-service-" + this.random8String();
final String classB = "10";
final String keyName = "key-" + this.random8String();
try {
this.createKey(keyName);
try {
this.createStack(context, vpcStackName, "vpc/vpc-2azs.yaml", new Parameter().withParameterKey("ClassB").withParameterValue(classB));
try {
this.createStack(context, clusterStackName, "ecs/cluster.yaml", new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName), new Parameter().withParameterKey("KeyName").withParameterValue(keyName));
final String cluster = this.getStackOutputValue(clusterStackName, "Cluster");
try {
this.createStack(context, stackName, "ecs/service-cluster-alb.yaml", new Parameter().withParameterKey("ParentClusterStack").withParameterValue(clusterStackName), new Parameter().withParameterKey("Image").withParameterValue("nginx:1.11.5"));
final String url = this.getStackOutputValue(stackName, "URL");
final Callable<Boolean> callable = () -> {
final HttpResponse response = WS.url(url).timeout(10000).get();
// check HTTP response code
if (WS.getStatus(response) != 404) {
throw new RuntimeException("404 expected, but saw " + WS.getStatus(response));
}
return true;
};
Assert.assertTrue("http response code is 404", this.retry(context, callable));
} finally {
this.deleteStack(context, stackName);
}
} finally {
this.deleteStack(context, clusterStackName);
}
} finally {
this.deleteStack(context, vpcStackName);
}
} finally {
this.deleteKey(context, keyName);
}
}
use of com.amazonaws.services.cloudformation.model.Parameter in project aws-cf-templates by widdix.
the class TestAccessLogsAnonymizer method cloudfront.
@Test
public void cloudfront() {
final Context context = new Context();
final String s3StackName = "s3-" + this.random8String();
final String anonymizerStackName = "anonymizer-" + this.random8String();
try {
this.createStack(context, s3StackName, "state/s3.yaml", new Parameter().withParameterKey("Access").withParameterValue("CloudFrontAccessLogWrite"));
try {
this.createStack(context, anonymizerStackName, "operations/cloudfront-access-logs-anonymizer.yaml", new Parameter().withParameterKey("ParentS3Stack").withParameterValue(s3StackName));
final String functionARN = this.getStackOutputValue(anonymizerStackName, "FunctionARN");
this.updateStack(context, s3StackName, "state/s3.yaml", new Parameter().withParameterKey("Access").withParameterValue("CloudFrontAccessLogWrite"), new Parameter().withParameterKey("LambdaFunctionArn").withParameterValue(functionARN));
// TODO upload file and test if IP addresses are anonymized
} finally {
this.deleteStack(context, anonymizerStackName);
}
} finally {
this.deleteStack(context, s3StackName);
}
}
Aggregations