CloudFormation

The first service we will look at is CloudFormation. This makes sense as the APIs found in here will give us a starting point for finding information about the resources in a given stack.

The describeStacks endpoint

This endpoint is responsible for listing all stacks associated with a particular AWS account. For a given stack, its response looks like the following:

{"Stacks"
   [{"StackId"
     "arn:aws:cloudformation:ap-southeast-2:337944750480:stack/DevStack-62031/1",
     "StackStatus" "CREATE_IN_PROGRESS",
     "StackName" "DevStack-62031",
     "Parameters" [{"ParameterKey" "DevDB", "ParameterValue" nil}]}]}

Unfortunately, it doesn't say anything about which resources belong to this stack. It does, however, give us the stack name, which we can use to look up resources in the next service.

The describeStackResources endpoint

This endpoint receives many arguments, but the one we're interested in is the stack name, which, once provided, returns the following:

{"StackResources"
   [{"PhysicalResourceId" "EC2123",
     "ResourceType" "AWS::EC2::Instance"},
    {"PhysicalResourceId" "EC2456",
     "ResourceType" "AWS::EC2::Instance"}
    {"PhysicalResourceId" "EC2789",
     "ResourceType" "AWS::EC2::Instance"}
    {"PhysicalResourceId" "RDS123",
     "ResourceType" "AWS::RDS::DBInstance"}
    {"PhysicalResourceId" "RDS456",
     "ResourceType" "AWS::RDS::DBInstance"}]}

We seem to be getting somewhere now. This stack has several resources: three EC2 instances and two RDS instances—not too bad for only two API calls.

However, as we mentioned previously, our dashboard needs to show the status of each of the resources. With the list of resource IDs at hand, we need to look to other services that could give us detailed information about each resource.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.120.57