public function testListStacksCommandAndIterator() { self::log('Execute a ListJobs command and iterator and verify that the results are the same.'); $commandResults = $this->client->listStacks()->toArray(); $this->assertArrayHasKey('StackSummaries', $commandResults); $iteratorResults = $this->client->getIterator('ListStacks')->toArray(); $this->assertEquals($commandResults['StackSummaries'], $iteratorResults); }
/** * Iterate over the results of a ListStacks operation * * @example Aws\CloudFormation\CloudFormationClient::listStacks */ public function testListStacksCommandAndIterator() { self::log('Execute a ListJobs command and iterator and verify that the results are the same.'); $client = $this->client; // @begin $result = $this->client->listStacks(); $stacks = $result['StackSummaries']; // Or load the stacks as an iterator $iterator = $client->getIterator('ListStacks'); $stacks = $iterator->toArray(); // @end $this->assertNotNull($stacks); $this->assertEquals($result['StackSummaries'], $stacks); }
public function testFactoryInitializesClient() { $client = CloudFormationClient::factory(array('key' => 'foo', 'secret' => 'bar', 'region' => 'us-west-2')); $this->assertInstanceOf('Aws\\Common\\Signature\\SignatureV4', $client->getSignature()); $this->assertInstanceOf('Aws\\Common\\Credentials\\Credentials', $client->getCredentials()); $this->assertEquals('https://cloudformation.us-west-2.amazonaws.com', $client->getBaseUrl()); }
/** * Return the physical resource id of a resource specified in a CloudFormation * stack. * * @param string $stackName Name or id of the stack. * @param string $resourceName Name of resource as specified in the * template. * @return string Phyiscal resource id. */ public function getCloudFormationPhysicalResourceIdByResourceName($stackName, $resourceName) { if (!strlen($stackName)) { throw new InvalidArgumentException(sprintf('Stack name passed to "%s" must be a non-zero length string', __FUNCTION__)); } if (!strlen($resourceName)) { throw new InvalidArgumentException(sprintf('Resource name passed to "%s" must be a non-zero length string', __FUNCTION__)); } try { $response = $this->cloudFormation->describeStackResource(['StackName' => $stackName, 'LogicalResourceId' => $resourceName]); } catch (CloudFormation\Exception\CloudFormationException $e) { if (preg_match('#Stack \'.*?\' does not exist#', $e->getMessage())) { return null; } throw new $e(); } if (!isset($response['StackResourceDetail'])) { throw new RuntimeException(sprintf('No resource with name "%s" found in stack "%s".', $resourceName, $stackName)); } return $response['StackResourceDetail']['PhysicalResourceId']; }
public function delete() { $this->cfnClient->deleteStack(['StackName' => $this->getName()]); return $this; }
/** * @param Stack $stack * @return CloudFormationClient */ private function cfn(Stack $stack) { return CloudFormationClient::factory($this->getAwsConfig($stack)); }