com.amazonaws.services.cloudformation.model.Parameter Java Examples
The following examples show how to use
com.amazonaws.services.cloudformation.model.Parameter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestDynamoDB.java From aws-cf-templates with Apache License 2.0 | 6 votes |
@Test public void testGSI() { final String stackName = "dynamodb-" + this.random8String(); try { this.createStack(stackName, "state/dynamodb.yaml", new Parameter().withParameterKey("PartitionKeyName").withParameterValue("id"), new Parameter().withParameterKey("SortKeyName").withParameterValue("timestamp"), new Parameter().withParameterKey("Attribute1Name").withParameterValue("organisation"), new Parameter().withParameterKey("Attribute2Name").withParameterValue("category"), new Parameter().withParameterKey("Index1PartitionKeyName").withParameterValue("timestamp"), new Parameter().withParameterKey("Index2PartitionKeyName").withParameterValue("organisation"), new Parameter().withParameterKey("Index2SortKeyName").withParameterValue("category") ); // TODO how can we check if this stack works? } finally { this.deleteStack(stackName); } }
Example #2
Source File: YAMLParameterFileParser.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
@Override public Collection<Parameter> parseParams(InputStream fileContent) throws IOException { Yaml yaml = new Yaml(new SafeConstructor()); @SuppressWarnings("unchecked") Map<String, Object> parse = yaml.load(new InputStreamReader(fileContent, Charsets.UTF_8)); Collection<Parameter> parameters = new ArrayList<>(); for (Map.Entry<String, Object> entry : parse.entrySet()) { Object value = entry.getValue(); if (value instanceof Collection) { String val = Joiner.on(",").join((Collection) value); parameters.add(new Parameter().withParameterKey(entry.getKey()).withParameterValue(val)); } else { parameters.add(new Parameter().withParameterKey(entry.getKey()).withParameterValue(value.toString())); } } return parameters; }
Example #3
Source File: ParameterParser.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
private static Collection<Parameter> parseParamsFile(FilePath workspace, String paramsFileName) { try { if (paramsFileName == null) { return Collections.emptyList(); } final ParameterFileParser parser; FilePath paramsFile = workspace.child(paramsFileName); if (paramsFile.getName().endsWith(".json")) { parser = new JSONParameterFileParser(); } else if (paramsFile.getName().endsWith(".yaml")) { parser = new YAMLParameterFileParser(); } else { throw new IllegalArgumentException("Invalid file extension for parameter file (supports json/yaml)"); } return parser.parseParams(paramsFile.read()); } catch (Exception e) { throw new IllegalArgumentException(e); } }
Example #4
Source File: CloudFormationStack.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
public Map<String, String> create(String templateBody, String templateUrl, Collection<Parameter> params, Collection<Tag> tags, Collection<String> notificationARNs, PollConfiguration pollConfiguration, String roleArn, String onFailure, Boolean enableTerminationProtection) throws ExecutionException { if ((templateBody == null || templateBody.isEmpty()) && (templateUrl == null || templateUrl.isEmpty())) { throw new IllegalArgumentException("Either a file or url for the template must be specified"); } CreateStackRequest req = new CreateStackRequest(); req.withStackName(this.stack).withCapabilities(Capability.CAPABILITY_IAM, Capability.CAPABILITY_NAMED_IAM, Capability.CAPABILITY_AUTO_EXPAND).withEnableTerminationProtection(enableTerminationProtection); req.withTemplateBody(templateBody).withTemplateURL(templateUrl).withParameters(params).withTags(tags).withNotificationARNs(notificationARNs) .withTimeoutInMinutes(pollConfiguration.getTimeout() == null ? null : (int) pollConfiguration.getTimeout().toMinutes()) .withRoleARN(roleArn) .withOnFailure(OnFailure.valueOf(onFailure)); this.client.createStack(req); new EventPrinter(this.client, this.listener).waitAndPrintStackEvents(this.stack, this.client.waiters().stackCreateComplete(), pollConfiguration); Map<String, String> outputs = this.describeOutputs(); outputs.put(UPDATE_STATUS_OUTPUT, "true"); return outputs; }
Example #5
Source File: JSONParameterFileParser.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
@Override public Collection<Parameter> parseParams(InputStream fileContent) throws IOException { ObjectMapper mapper = new ObjectMapper(); JsonNode tree = mapper.readTree(fileContent); Collection<Parameter> parameters = new ArrayList<>(); if (tree instanceof ArrayNode) { ArrayNode jsonNodes = (ArrayNode) tree; for (JsonNode node : jsonNodes) { Parameter param = new Parameter(); param.withParameterKey(node.get("ParameterKey").asText()); if (node.has("ParameterValue")) { param.withParameterValue(node.get("ParameterValue").asText()); } if (node.has("UsePreviousValue")) { param.withUsePreviousValue(node.get("UsePreviousValue").booleanValue()); } parameters.add(param); } } return parameters; }
Example #6
Source File: CloudFormationStackSet.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
public CreateStackSetResult create(String templateBody, String templateUrl, Collection<Parameter> params, Collection<Tag> tags, String administratorRoleArn, String executionRoleName) { if ((templateBody == null || templateBody.isEmpty()) && (templateUrl == null || templateUrl.isEmpty())) { throw new IllegalArgumentException("Either a file or url for the template must be specified"); } this.listener.getLogger().println("Creating stack set " + this.stackSet); CreateStackSetRequest req = new CreateStackSetRequest() .withStackSetName(this.stackSet) .withCapabilities(Capability.CAPABILITY_IAM, Capability.CAPABILITY_NAMED_IAM, Capability.CAPABILITY_AUTO_EXPAND) .withTemplateBody(templateBody) .withTemplateURL(templateUrl) .withParameters(params) .withAdministrationRoleARN(administratorRoleArn) .withExecutionRoleName(executionRoleName) .withTags(tags); CreateStackSetResult result = this.client.createStackSet(req); this.listener.getLogger().println("Created Stack set stackSetId=" + result.getStackSetId()); return result; }
Example #7
Source File: TestFargateCluster.java From aws-cf-templates with Apache License 2.0 | 6 votes |
@Test public void test() { final String vpcStackName = "vpc-2azs-" + this.random8String(); final String stackName = "fargate-cluster-" + this.random8String(); final String classB = "10"; try { this.createStack(vpcStackName, "vpc/vpc-2azs.yaml", new Parameter().withParameterKey("ClassB").withParameterValue(classB) ); try { this.createStack(stackName, "fargate/cluster.yaml", new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName) ); } finally { this.deleteStack(stackName); } } finally { this.deleteStack(vpcStackName); } }
Example #8
Source File: TestVPCEndpointDynamoDB.java From aws-cf-templates with Apache License 2.0 | 6 votes |
@Test public void test() { final String vpcStackName = "vpc-2azs-" + this.random8String(); final String endpointStackName = "vpc-endpoint-dynamodb-" + this.random8String(); final String classB = "10"; try { this.createStack(vpcStackName, "vpc/vpc-2azs.yaml", new Parameter().withParameterKey("ClassB").withParameterValue(classB) ); try { this.createStack(endpointStackName, "vpc/vpc-endpoint-dynamodb.yaml", new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName) ); // TODO how can we check if this stack works? } finally { this.deleteStack(endpointStackName); } } finally { this.deleteStack(vpcStackName); } }
Example #9
Source File: CFNUpdateStackSetStepTest.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
@Test public void createNonExistantStackWithCustomAdminArn() throws Exception { WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "testStepWithGlobalCredentials"); Mockito.when(stackSet.exists()).thenReturn(false); job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " cfnUpdateStackSet(stackSet: 'foo', administratorRoleArn: 'bar', executionRoleName: 'baz')" + "}\n", true) ); jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0)); PowerMockito.verifyNew(CloudFormationStackSet.class, Mockito.atLeastOnce()) .withArguments( Mockito.any(AmazonCloudFormation.class), Mockito.eq("foo"), Mockito.any(TaskListener.class), Mockito.eq(SleepStrategy.EXPONENTIAL_BACKOFF_STRATEGY) ); Mockito.verify(stackSet).create(Mockito.anyString(), Mockito.anyString(), Mockito.anyCollectionOf(Parameter.class), Mockito.anyCollectionOf(Tag.class), Mockito.eq("bar"), Mockito.eq("baz")); }
Example #10
Source File: TestVPCNatGateway.java From aws-cf-templates with Apache License 2.0 | 6 votes |
@Test public void test() { final String vpcStackName = "vpc-2azs-" + this.random8String(); final String natStackName = "vpc-nat-gateway-" + this.random8String(); final String classB = "10"; try { this.createStack(vpcStackName, "vpc/vpc-2azs.yaml", new Parameter().withParameterKey("ClassB").withParameterValue(classB) ); try { this.createStack(natStackName, "vpc/vpc-nat-gateway.yaml", new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName) ); this.testVPCSubnetInternetAccess(vpcStackName, "SubnetAPrivate"); } finally { this.deleteStack(natStackName); } } finally { this.deleteStack(vpcStackName); } }
Example #11
Source File: CFNUpdateStackSetStepTest.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
@Test public void doNotCreateNonExistantStack() throws Exception { WorkflowJob job = jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest"); Mockito.when(stackSet.exists()).thenReturn(false); job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " cfnUpdateStackSet(stackSet: 'foo', create: false)" + "}\n", true) ); jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0)); PowerMockito.verifyNew(CloudFormationStackSet.class, Mockito.atLeastOnce()) .withArguments( Mockito.any(AmazonCloudFormation.class), Mockito.eq("foo"), Mockito.any(TaskListener.class), Mockito.eq(SleepStrategy.EXPONENTIAL_BACKOFF_STRATEGY) ); Mockito.verify(stackSet, Mockito.never()).create(Mockito.anyString(), Mockito.anyString(), Mockito.anyCollectionOf(Parameter.class), Mockito.anyCollectionOf(Tag.class), Mockito.isNull(String.class), Mockito.isNull(String.class)); }
Example #12
Source File: CFNCreateChangeSetTests.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
@Test public void createChangeSetWithRawTemplate() throws Exception { WorkflowJob job = this.jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest"); Mockito.when(this.stack.exists()).thenReturn(true); Mockito.when(this.stack.describeChangeSet("bar")).thenReturn(new DescribeChangeSetResult() .withChanges(new Change()) .withStatus(ChangeSetStatus.CREATE_COMPLETE) ); job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " def changes = cfnCreateChangeSet(stack: 'foo', changeSet: 'bar', template: 'foobaz')\n" + " echo \"changesCount=${changes.size()}\"\n" + "}\n", true) ); Run run = this.jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0)); this.jenkinsRule.assertLogContains("changesCount=1", run); PowerMockito.verifyNew(CloudFormationStack.class, Mockito.atLeastOnce()).withArguments(Mockito.any(AmazonCloudFormation.class), Mockito.eq("foo"), Mockito.any(TaskListener.class)); Mockito.verify(this.stack).createChangeSet(Mockito.eq("bar"), Mockito.eq("foobaz"), Mockito.anyString(), Mockito.anyCollectionOf(Parameter.class), Mockito.anyCollectionOf(Tag.class), Mockito.anyCollectionOf(String.class), Mockito.any(PollConfiguration.class), Mockito.eq(ChangeSetType.UPDATE), Mockito.anyString(), Mockito.any()); }
Example #13
Source File: CFNCreateChangeSetTests.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
@Test public void updateChangeSetWithRawTemplate() throws Exception { WorkflowJob job = this.jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest"); Mockito.when(this.stack.exists()).thenReturn(false); Mockito.when(this.stack.describeChangeSet("bar")).thenReturn(new DescribeChangeSetResult() .withChanges(new Change()) .withStatus(ChangeSetStatus.CREATE_COMPLETE) ); job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " def changes = cfnCreateChangeSet(stack: 'foo', changeSet: 'bar', template: 'foobaz')\n" + " echo \"changesCount=${changes.size()}\"\n" + "}\n", true) ); Run run = this.jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0)); this.jenkinsRule.assertLogContains("changesCount=1", run); PowerMockito.verifyNew(CloudFormationStack.class, Mockito.atLeastOnce()).withArguments(Mockito.any(AmazonCloudFormation.class), Mockito.eq("foo"), Mockito.any(TaskListener.class)); Mockito.verify(this.stack).createChangeSet(Mockito.eq("bar"), Mockito.eq("foobaz"), Mockito.anyString(), Mockito.anyCollectionOf(Parameter.class), Mockito.anyCollectionOf(Tag.class), Mockito.anyCollectionOf(String.class), Mockito.any(PollConfiguration.class), Mockito.eq(ChangeSetType.CREATE), Mockito.anyString(), Mockito.any()); }
Example #14
Source File: CFNCreateChangeSetTests.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
@Test public void createChangeSetStackDoesNotExist() throws Exception { WorkflowJob job = this.jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest"); Mockito.when(this.stack.exists()).thenReturn(false); Mockito.when(this.stack.describeChangeSet("bar")).thenReturn(new DescribeChangeSetResult() .withChanges(new Change()) .withStatus(ChangeSetStatus.CREATE_COMPLETE) ); job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " def changes = cfnCreateChangeSet(stack: 'foo', changeSet: 'bar')\n" + " echo \"changesCount=${changes.size()}\"\n" + "}\n", true) ); Run run = this.jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0)); this.jenkinsRule.assertLogContains("changesCount=1", run); PowerMockito.verifyNew(CloudFormationStack.class, Mockito.atLeastOnce()).withArguments(Mockito.any(AmazonCloudFormation.class), Mockito.eq("foo"), Mockito.any(TaskListener.class)); Mockito.verify(this.stack).createChangeSet(Mockito.eq("bar"), Mockito.anyString(), Mockito.anyString(), Mockito.anyCollectionOf(Parameter.class), Mockito.anyCollectionOf(Tag.class), Mockito.anyCollectionOf(String.class), Mockito.any(PollConfiguration.class), Mockito.eq(ChangeSetType.CREATE), Mockito.anyString(), Mockito.any()); }
Example #15
Source File: TestShowcase.java From aws-ec2-ssh with MIT License | 6 votes |
@Test public void testCentOS() throws Exception { final String stackName = "showcase-" + this.random8String(); final String userName = "user-" + this.random8String(); try { final User user = this.createUser(userName); try { this.createStack(stackName, "showcase.yaml", new Parameter().withParameterKey("VPC").withParameterValue(this.getDefaultVPC().getVpcId()), new Parameter().withParameterKey("Subnet").withParameterValue(this.getDefaultSubnets().get(0).getSubnetId()), new Parameter().withParameterKey("OS").withParameterValue("CentOS") ); final String host = this.getStackOutputValue(stackName, "PublicName"); this.probeSSH(host, user); } finally { this.deleteStack(stackName); } } finally { this.deleteUser(userName); } }
Example #16
Source File: TestShowcase.java From aws-ec2-ssh with MIT License | 6 votes |
@Test public void testRHEL() throws Exception { final String stackName = "showcase-" + this.random8String(); final String userName = "user-" + this.random8String(); try { final User user = this.createUser(userName); try { this.createStack(stackName, "showcase.yaml", new Parameter().withParameterKey("VPC").withParameterValue(this.getDefaultVPC().getVpcId()), new Parameter().withParameterKey("Subnet").withParameterValue(this.getDefaultSubnets().get(0).getSubnetId()), new Parameter().withParameterKey("OS").withParameterValue("RHEL") ); final String host = this.getStackOutputValue(stackName, "PublicName"); this.probeSSH(host, user); } finally { this.deleteStack(stackName); } } finally { this.deleteUser(userName); } }
Example #17
Source File: TestShowcase.java From aws-ec2-ssh with MIT License | 6 votes |
@Test public void testUbuntu() throws Exception { final String stackName = "showcase-" + this.random8String(); final String userName = "user-" + this.random8String(); try { final User user = this.createUser(userName); try { this.createStack(stackName, "showcase.yaml", new Parameter().withParameterKey("VPC").withParameterValue(this.getDefaultVPC().getVpcId()), new Parameter().withParameterKey("Subnet").withParameterValue(this.getDefaultSubnets().get(0).getSubnetId()), new Parameter().withParameterKey("OS").withParameterValue("Ubuntu") ); final String host = this.getStackOutputValue(stackName, "PublicName"); this.probeSSH(host, user); } finally { this.deleteStack(stackName); } } finally { this.deleteUser(userName); } }
Example #18
Source File: CFNCreateChangeSetTests.java From pipeline-aws-plugin with Apache License 2.0 | 6 votes |
@Test public void createChangeSetStackParametersFromMap() throws Exception { WorkflowJob job = this.jenkinsRule.jenkins.createProject(WorkflowJob.class, "cfnTest"); Mockito.when(this.stack.exists()).thenReturn(true); Mockito.when(this.stack.describeChangeSet("bar")).thenReturn(new DescribeChangeSetResult() .withChanges(new Change()) .withStatus(ChangeSetStatus.CREATE_COMPLETE) ); job.setDefinition(new CpsFlowDefinition("" + "node {\n" + " def changes = cfnCreateChangeSet(stack: 'foo', changeSet: 'bar', params: ['foo': 'bar', 'baz': 'true'])\n" + " echo \"changesCount=${changes.size()}\"\n" + "}\n", true) ); Run run = this.jenkinsRule.assertBuildStatusSuccess(job.scheduleBuild2(0)); this.jenkinsRule.assertLogContains("changesCount=1", run); PowerMockito.verifyNew(CloudFormationStack.class, Mockito.atLeastOnce()).withArguments(Mockito.any(AmazonCloudFormation.class), Mockito.eq("foo"), Mockito.any(TaskListener.class)); Mockito.verify(this.stack).createChangeSet(Mockito.eq("bar"), Mockito.anyString(), Mockito.anyString(), Mockito.eq(Arrays.asList( new Parameter().withParameterKey("foo").withParameterValue("bar"), new Parameter().withParameterKey("baz").withParameterValue("true") )), Mockito.anyCollectionOf(Tag.class), Mockito.anyCollectionOf(String.class), Mockito.any(PollConfiguration.class), Mockito.eq(ChangeSetType.UPDATE), Mockito.anyString(), Mockito.any()); }
Example #19
Source File: TestWrapper.java From herd-mdl with Apache License 2.0 | 6 votes |
private static void saveStackInputProperties(String stackName) throws Exception { LOGGER.info("Save some stack inputs to file test.props for stack: " + stackName); try (BufferedWriter writer = new BufferedWriter(new FileWriter(new File("mdlt/conf/test.props"), true))) { CloudFormationClient cfClient = new CloudFormationClient(stackName); List<Parameter> stackInputParameters = cfClient.getStackByName(stackName).getParameters(); Parameter env = stackInputParameters.stream() .filter(parameter -> parameter.getParameterKey().equals(StackInputParameterKeyEnum.ENVIRONMENT.getKey())) .findFirst().get(); writer.write(env.getParameterKey() + "=" + env.getParameterValue()); writer.newLine(); Parameter instanceName = stackInputParameters.stream() .filter(parameter -> parameter.getParameterKey().equals(StackInputParameterKeyEnum.MDL_INSTANCE_NAME.getKey())) .findFirst().get(); writer.write(StackInputParameterKeyEnum.MDL_INSTANCE_NAME.getKey() + "=" + instanceName.getParameterValue()); writer.newLine(); } }
Example #20
Source File: TestShowcase.java From aws-ec2-ssh with MIT License | 6 votes |
@Test public void testAmazonLinux2() throws Exception { final String stackName = "showcase-" + this.random8String(); final String userName = "user-" + this.random8String(); try { final User user = this.createUser(userName); try { this.createStack(stackName, "showcase.yaml", new Parameter().withParameterKey("VPC").withParameterValue(this.getDefaultVPC().getVpcId()), new Parameter().withParameterKey("Subnet").withParameterValue(this.getDefaultSubnets().get(0).getSubnetId()), new Parameter().withParameterKey("OS").withParameterValue("AmazonLinux2") ); final String host = this.getStackOutputValue(stackName, "PublicName"); this.probeSSH(host, user); } finally { this.deleteStack(stackName); } } finally { this.deleteUser(userName); } }
Example #21
Source File: TestDynamoDB.java From aws-cf-templates with Apache License 2.0 | 6 votes |
@Test public void testEncryption() { final String kmsKeyStackName = "key-" + this.random8String(); final String stackName = "dynamodb-" + this.random8String(); try { this.createStack(kmsKeyStackName,"security/kms-key.yaml"); try { this.createStack(stackName, "state/dynamodb.yaml", new Parameter().withParameterKey("ParentKmsKeyStack").withParameterValue(kmsKeyStackName), new Parameter().withParameterKey("PartitionKeyName").withParameterValue("id") ); // TODO how can we check if this stack works? } finally { this.deleteStack(stackName); } } finally { this.deleteStack(kmsKeyStackName); } }
Example #22
Source File: TestTerraformState.java From aws-cf-templates with Apache License 2.0 | 6 votes |
@Test public void test() { final String kmsStackName = "kms-" + this.random8String(); final String terraformStateStackName = "tf-state-" + this.random8String(); try { this.createStack(kmsStackName, "security/kms-key.yaml", new Parameter().withParameterKey("Service").withParameterValue("s3") ); try { this.createStack(terraformStateStackName, "operations/terraform-state.yaml", new Parameter().withParameterKey("ParentKmsKeyStack").withParameterValue(kmsStackName), new Parameter().withParameterKey("TerraformStateIdentifier").withParameterValue(terraformStateStackName), new Parameter().withParameterKey("TerraformStateAdminARNs").withParameterValue("arn:aws:iam::" + this.getAccount() + ":root," + System.getenv("IAM_ROLE_ARN") + "," + this.getCallerIdentityArn()) ); } finally { this.deleteStack(terraformStateStackName); } } finally { this.deleteStack(kmsStackName); } }
Example #23
Source File: TestS3VirusScan.java From aws-s3-virusscan with Apache License 2.0 | 5 votes |
@Test public void testManyFiles() { final String vpcStackName = "vpc-2azs-" + this.random8String(); final String stackName = "s3-virusscan-" + this.random8String(); final String bucketName = "s3-virusscan-" + this.random8String(); final InfectedFileCache cache = new InfectedFileCache(); try { this.createWiddixStack(vpcStackName, "vpc/vpc-2azs.yaml"); try { this.createStack(stackName, "template.yaml", new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName) ); try { this.createBucket(bucketName, this.getStackOutputValue(stackName, "ScanQueueArn")); cache.getFiles().forEach(file -> this.createObject(bucketName, file.getkey(), file.getContent(), file.getContentType(), file.getContentLength())); this.retry(() -> { if (this.countBucket(bucketName) != 0) { // all files are expected to be deleted throw new RuntimeException("there are infected files left"); } return false; }); } finally { this.deleteBucket(bucketName); } } finally { this.deleteStack(stackName); } } finally { this.deleteStack(vpcStackName); } }
Example #24
Source File: TestS3VirusScan.java From aws-s3-virusscan with Apache License 2.0 | 5 votes |
@Test public void testWithFileDeletion() { final String vpcStackName = "vpc-2azs-" + this.random8String(); final String stackName = "s3-virusscan-" + this.random8String(); final String bucketName = "s3-virusscan-" + this.random8String(); try { this.createWiddixStack(vpcStackName, "vpc/vpc-2azs.yaml"); try { this.createStack(stackName, "template.yaml", new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName) ); try { this.createBucket(bucketName, this.getStackOutputValue(stackName, "ScanQueueArn")); this.createObject(bucketName, "no-virus.txt", "not a virus"); this.createObject(bucketName, "virus.txt", "X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*"); this.retry(() -> { if (this.doesObjectExist(bucketName, "virus.txt") == true) { // expected to be deleted throw new RuntimeException("virus.txt must be deleted"); } return false; }); this.retry(() -> { if (this.doesObjectExist(bucketName, "no-virus.txt") == false) { // expected to exist throw new RuntimeException("no-virus.txt must be existing"); } return true; }); this.deleteObject(bucketName, "no-virus.txt"); } finally { this.deleteBucket(bucketName); } } finally { this.deleteStack(stackName); } } finally { this.deleteStack(vpcStackName); } }
Example #25
Source File: TestShowcaseRPM.java From aws-ec2-ssh with MIT License | 5 votes |
@Test public void testSUSELinuxEnterpriseServer() throws Exception { final String stackName = "showcase-rpm-" + this.random8String(); final String userName = "user-" + this.random8String(); try { final User user = this.createUser(userName); try { if (Config.has(Config.Key.VERSION)) { this.createStack(stackName, "showcase-rpm.yaml", new Parameter().withParameterKey("VPC").withParameterValue(this.getDefaultVPC().getVpcId()), new Parameter().withParameterKey("Subnet").withParameterValue(this.getDefaultSubnets().get(0).getSubnetId()), new Parameter().withParameterKey("OS").withParameterValue("SUSELinuxEnterpriseServer"), new Parameter().withParameterKey("Version").withParameterValue(Config.get(Config.Key.VERSION)) ); } else { this.createStack(stackName, "showcase-rpm.yaml", new Parameter().withParameterKey("VPC").withParameterValue(this.getDefaultVPC().getVpcId()), new Parameter().withParameterKey("Subnet").withParameterValue(this.getDefaultSubnets().get(0).getSubnetId()), new Parameter().withParameterKey("OS").withParameterValue("SUSELinuxEnterpriseServer") ); } final String host = this.getStackOutputValue(stackName, "PublicName"); this.probeSSH(host, user); } finally { this.deleteStack(stackName); } } finally { this.deleteUser(userName); } }
Example #26
Source File: TestVPCSshBastion.java From aws-cf-templates with Apache License 2.0 | 5 votes |
@Test public void test() { final String vpcStackName = "vpc-2azs-" + this.random8String(); final String bastionStackName = "vpc-ssh-bastion-" + this.random8String(); final String classB = "10"; final String keyName = "key-" + this.random8String(); try { final KeyPair key = this.createKey(keyName); try { this.createStack(vpcStackName, "vpc/vpc-2azs.yaml", new Parameter().withParameterKey("ClassB").withParameterValue(classB) ); try { this.createStack(bastionStackName, "vpc/vpc-ssh-bastion.yaml", new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName), new Parameter().withParameterKey("KeyName").withParameterValue(keyName) ); final String host = this.getStackOutputValue(bastionStackName, "IPAddress"); this.probeSSH(host, key); } finally { this.deleteStack(bastionStackName); } } finally { this.deleteStack(vpcStackName); } } finally { this.deleteKey(keyName); } }
Example #27
Source File: TestDocumentDB.java From aws-cf-templates with Apache License 2.0 | 5 votes |
@Test public void test() { final String vpcStackName = "vpc-2azs-" + this.random8String(); final String clientStackName = "client-" + this.random8String(); final String stackName = "documentdb-" + this.random8String(); try { this.createStack(vpcStackName, "vpc/vpc-2azs.yaml"); try { this.createStack(clientStackName, "state/client-sg.yaml", new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName) ); try { this.createStack(stackName, "state/documentdb.yaml", new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName), new Parameter().withParameterKey("ParentClientStack").withParameterValue(clientStackName), new Parameter().withParameterKey("MasterUserPassword").withParameterValue("Test!1234") ); // TODO how can we check if this stack works? start a bastion host and try to connect? } finally { this.deleteStack(stackName); } } finally { this.deleteStack(clientStackName); } } finally { this.deleteStack(vpcStackName); } }
Example #28
Source File: TestEC2AutoRecovery.java From aws-cf-templates with Apache License 2.0 | 5 votes |
@Test public void test() { final String vpcStackName = "vpc-2azs-" + this.random8String(); final String stackName = "ec2-auto-recovery-" + this.random8String(); final String classB = "10"; final String keyName = "key-" + this.random8String(); try { final KeyPair key = this.createKey(keyName); try { this.createStack(vpcStackName, "vpc/vpc-2azs.yaml", new Parameter().withParameterKey("ClassB").withParameterValue(classB) ); try { this.createStack(stackName, "ec2/ec2-auto-recovery.yaml", new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName), new Parameter().withParameterKey("KeyName").withParameterValue(keyName) ); final String host = this.getStackOutputValue(stackName, "IPAddress"); this.probeSSH(host, key); } finally { this.deleteStack(stackName); } } finally { this.deleteStack(vpcStackName); } } finally { this.deleteKey(keyName); } }
Example #29
Source File: TestAL2MutablePrivate.java From aws-cf-templates with Apache License 2.0 | 5 votes |
@Test public void test() { final String vpcStackName = "vpc-2azs-" + this.random8String(); final String natStackName = "vpc-nat-gateway-" + this.random8String(); final String stackName = "al2-mutable-private-" + this.random8String(); final String classB = "10"; try { this.createStack(vpcStackName, "vpc/vpc-2azs.yaml", new Parameter().withParameterKey("ClassB").withParameterValue(classB) ); try { this.createStack(natStackName, "vpc/vpc-nat-gateway.yaml", new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName) ); try { this.createStack(stackName, "ec2/al2-mutable-private.yaml", new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName) ); // TODO how can we check if this stack works? } finally { this.deleteStack(stackName); } } finally { this.deleteStack(natStackName); } } finally { this.deleteStack(vpcStackName); } }
Example #30
Source File: TestEC2AutoRecovery.java From aws-cf-templates with Apache License 2.0 | 5 votes |
@Test public void testWithIAMUserSSHAccess() throws Exception { final String vpcStackName = "vpc-2azs-" + this.random8String(); final String stackName = "ec2-auto-recovery-" + this.random8String(); final String classB = "10"; final String userName = "user-" + this.random8String(); try { final User user = this.createUser(userName); try { this.createStack(vpcStackName, "vpc/vpc-2azs.yaml", new Parameter().withParameterKey("ClassB").withParameterValue(classB) ); try { this.createStack(stackName, "ec2/ec2-auto-recovery.yaml", new Parameter().withParameterKey("ParentVPCStack").withParameterValue(vpcStackName), new Parameter().withParameterKey("IAMUserSSHAccess").withParameterValue("true") ); final String host = this.getStackOutputValue(stackName, "IPAddress"); this.probeSSH(host, user); } finally { this.deleteStack(stackName); } } finally { this.deleteStack(vpcStackName); } } finally { this.deleteUser(userName); } }