Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed errors while running AWS cloudformation query to list the stacks Closes #1954 #1959

Merged
merged 8 commits into from
Mar 14, 2024

Conversation

ParthaI
Copy link
Contributor

@ParthaI ParthaI commented Nov 7, 2023

Integration test logs

Logs
No env file present for the current environment:  staging 
 Falling back to .env config
No env file present for the current environment:  staging
customEnv TURBOT_TEST_EXPECTED_TIMEOUT undefined

SETUP: tests/aws_cloudformation_stack []

PRETEST: tests/aws_cloudformation_stack

TEST: tests/aws_cloudformation_stack
Running terraform
data.aws_caller_identity.current: Reading...
data.aws_region.alternate: Reading...
data.aws_partition.current: Reading...
data.aws_region.primary: Reading...
data.aws_region.alternate: Read complete after 0s [id=us-east-2]
data.aws_region.primary: Read complete after 0s [id=us-east-1]
data.aws_partition.current: Read complete after 0s [id=aws]
data.aws_caller_identity.current: Read complete after 2s [id=333333333333]
data.null_data_source.resource: Reading...
data.null_data_source.resource: Read complete after 0s [id=static]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_cloudformation_stack.named_test_resource will be created
  + resource "aws_cloudformation_stack" "named_test_resource" {
      + id            = (known after apply)
      + name          = "turbottest85061"
      + outputs       = (known after apply)
      + parameters    = (known after apply)
      + policy_body   = (known after apply)
      + tags          = {
          + "name" = "turbottest85061"
        }
      + tags_all      = {
          + "name" = "turbottest85061"
        }
      + template_body = jsonencode(
            {
              + Resources = {
                  + CloudFormationStackTest = {
                      + Type = "AWS::SQS::Queue"
                    }
                }
            }
        )
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + account_id    = "333333333333"
  + region_name   = "us-east-1"
  + resource_aka  = (known after apply)
  + resource_name = "turbottest85061"
aws_cloudformation_stack.named_test_resource: Creating...
aws_cloudformation_stack.named_test_resource: Still creating... [10s elapsed]
aws_cloudformation_stack.named_test_resource: Creation complete after 14s [id=arn:aws:cloudformation:us-east-1:333333333333:stack/turbottest85061/08872a50-7d47-11ee-93c0-0aa9c1ec9da1]

Warning: Deprecated

  with data.null_data_source.resource,
  on variables.tf line 44, in data "null_data_source" "resource":
  44: data "null_data_source" "resource" {

The null_data_source was historically used to construct intermediate values
to re-use elsewhere in configuration, the same can now be achieved using
locals

(and one more similar warning elsewhere)

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Outputs:

account_id = "333333333333"
region_name = "us-east-1"
resource_aka = "arn:aws:cloudformation:us-east-1:333333333333:stack/turbottest85061/08872a50-7d47-11ee-93c0-0aa9c1ec9da1"
resource_name = "turbottest85061"

Running SQL query: query.sql
Warning: terminal options has been deprecated and will be removed in a future version of Steampipe.
These can now be set in a steampipe workspace.
(/Users/parthas/.steampipe/config/default.spc:34,20-42,2)
[
  {
    "name": "turbottest85061",
    "tags_src": [
      {
        "Key": "name",
        "Value": "turbottest85061"
      }
    ]
  }
]
✔ PASSED

Running SQL query: test-get-query.sql
Warning: terminal options has been deprecated and will be removed in a future version of Steampipe.
These can now be set in a steampipe workspace.
(/Users/parthas/.steampipe/config/default.spc:34,20-42,2)
[
  {
    "akas": [
      "arn:aws:cloudformation:us-east-1:333333333333:stack/turbottest85061/08872a50-7d47-11ee-93c0-0aa9c1ec9da1"
    ],
    "id": "arn:aws:cloudformation:us-east-1:333333333333:stack/turbottest85061/08872a50-7d47-11ee-93c0-0aa9c1ec9da1",
    "name": "turbottest85061",
    "tags": {
      "name": "turbottest85061"
    },
    "title": "turbottest85061"
  }
]
✔ PASSED

Running SQL query: test-list-query.sql
Warning: terminal options has been deprecated and will be removed in a future version of Steampipe.
These can now be set in a steampipe workspace.
(/Users/parthas/.steampipe/config/default.spc:34,20-42,2)
[
  {
    "akas": [
      "arn:aws:cloudformation:us-east-1:333333333333:stack/turbottest85061/08872a50-7d47-11ee-93c0-0aa9c1ec9da1"
    ],
    "id": "arn:aws:cloudformation:us-east-1:333333333333:stack/turbottest85061/08872a50-7d47-11ee-93c0-0aa9c1ec9da1",
    "name": "turbottest85061",
    "tags": {
      "name": "turbottest85061"
    },
    "title": "turbottest85061"
  }
]
✔ PASSED

POSTTEST: tests/aws_cloudformation_stack

TEARDOWN: tests/aws_cloudformation_stack

SUMMARY:

1/1 passed.

Example query results

Results
> select name, template_body_json from aws_aab.aws_cloudformation_stack
+------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
| name                                                                         | template_body_json                                                                                                                                                                          >
+------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------->
| CloudWatch-CrossAccountSharingRole                                           | {"AWSTemplateFormatVersion":"2010-09-09","Conditions":{"DoAutomaticDashboards":["Policy","CloudWatch-and-AutomaticDashboards"],"DoCWReadOnly":["Policy","CloudWatch-core-permissions"],"DoFu>
|                                                                              | to give to the Monitoring accounts","Type":"String"}},"Resources":{"CWCrossAccountSharingRole":{"Properties":{"AssumeRolePolicyDocument":{"Statement":[{"Action":["sts:AssumeRole"],"Effect">
|                                                                              | :aws:policy/AWSXrayReadOnlyAccess"],["arn:aws:iam::aws:policy/CloudWatchReadOnlyAccess"]]]]],"Path":"/","RoleName":"CloudWatch-CrossAccountSharingRole"},"Type":"AWS::IAM::Role"}}}         >
| Infra-ECS-Cluster-cluster-with-instance-c115de83                             | {"AWSTemplateFormatVersion":"2010-09-09","Description":"The template used to create an ECS Cluster from the ECS Console.","Outputs":{"ECSCluster":{"Description":"The created cluster.","Val>
|                                                                              | on":{"Properties":{"CapacityProviders":["FARGATE","FARGATE_SPOT",{"Ref":"EC2CapacityProvider"}],"Cluster":"cluster-with-instance","DefaultCapacityProviderStrategy":[{"Base":0,"CapacityProv>
|                                                                              | r"}}}                                                                                                                                                                                       >
| aab                                                                          | {"AWSTemplateFormatVersion":"2010-09-09","Mappings":{"ElbAccounts":{"ap-northeast-1":{"AccountId":"333333333333"},"ap-northeast-2":{"AccountId":"333333333334"},"ap-south-1":{"AccountId":"7>
|                                                                              | d":"333333333374"},"ap-southeast-2":{"AccountId":"333333333364"},"ca-central-1":{"AccountId":"333333333302"},"eu-central-1":{"AccountId":"333333333356"},"eu-north-1":{"AccountId":"72991109>
|                                                                              | ,"Id":"Delete after 1 days: TurbotLogs/Backups/*","NoncurrentVersionExpirationInDays":"1","Prefix":"TurbotLogs/Backups/","Status":"Enabled"},{"ExpirationInDays":"1","Id":"Delete after 1 da>
|                                                                              | ner-full-control"}},"Effect":"Allow","Principal":{"Service":"cloudtrail.amazonaws.com"},"Resource":{"Fn::Join":["",["arn:aws:s3:::",{"Ref":"APSO1"},"/AWSLogs/",{"Ref":"AWS::AccountId"},"/*>
|                                                                              | aws:iam::",{"Fn::FindInMap":["RedshiftAccounts",{"Ref":"AWS::Region"},"AccountId"]},":user/logs"]]},"Service":"cloudtrail.amazonaws.com"},"Resource":{"Fn::Join":["",["arn:aws:s3:::",{"Ref">
| databricks-workspace-stack-8f3fd                                             | {"AWSTemplateFormatVersion":"2010-09-09","Conditions":{"IsTrialAccount":["AccountType","Trial"]},"Description":"Set up resources and deploy a Databricks workspace in your AWS account. If y>
|                                                                              | d"},"DatabricksAccountId":{"Description":"Databricks account ID","Value":"createCredentials.ExternalId"},"MetastoreIAMRoleARN":{"Description":"ARN of the IAM role for metastore","Value":"m>
|                                                                              | eWorkspace.WorkspaceStatusMsg"},"WorkspaceURL":{"Description":"URL of the workspace","Value":["",["https://","createWorkspace.DeploymentName",".cloud.databricks.com"]]}},"Parameters":{"Acc>
|                                                                              |  for this workspace.","MaxLength":"64","MinLength":"1","Type":"String"}},"Resources":{"CopyZips":{"Properties":{"DestBucket":"LambdaZipsBucket","Objects":["functions/packages/default-clust>
|                                                                              |   objects = {'Objects': [{'Key': prefix + o} for o in objects]}\n    s3.delete_objects(Bucket=bucket, Delete=objects)\ndef timeout(event, context):\n    logging.error('Execution is about t>
|                                                                              | prefix, objects)\n        else:\n            copy_objects(source_bucket, dest_bucket, prefix, objects)\n    except Exception as e:\n        logging.error('Exception: %s' % e, exc_info=True>
|                                                                              | ","s3:DeleteObject"],"Effect":"Allow","Resource":["arn:${AWS::Partition}:s3:::${LambdaZipsBucket}/*"]}],"Version":"2012-10-17"},"PolicyName":"lambda-copier"}],"Tags":[{"Key":"Name","Value">
|                                                                              | t":"databricks-CloudFormation-Trial-inhouse-default-cluster-grow-553-uc-as-the-default"},"Type":"Custom::CreateCredentials"},"createMetastore":{"Properties":{"ServiceToken":"databricksApiF>
|                                                                              | ttps://${createWorkspace.DeploymentName}.cloud.databricks.com"},"Type":"Custom::CreateSharedCatalog"},"createStorageConfiguration":{"Properties":{"ServiceToken":"databricksApiFunction.Arn">
|                                                                              | onfiguration.StorageConfigId","user_agent":"databricks-CloudFormation-Trial-inhouse-default-cluster-grow-553-uc-as-the-default","workspace_name":"WorkspaceName"},"Type":"Custom::CreateWork>
|                                                                              | "cfn-lint":{"config":{"ignore_checks":["EIAMPolicyWildcardResource"],"ignore_reasons":{"EIAMPolicyWildcardResource":"Need to manage databricks metastore"}}}},"Properties":{"AssumeRolePolic>
|                                                                              | bject","s3:ListBucket","s3:GetBucketLocation","s3:GetLifecycleConfiguration","s3:PutLifecycleConfiguration"],"Effect":"Allow","Resource":["arn:aws:s3:::${metastoreS3Bucket}/*","arn:aws:s3:>
|                                                                              | "StringEquals":{"sts:ExternalId":"${AccountId}"}},"Effect":"Allow","Principal":{"AWS":"arn:aws:iam::414351767826:root"},"Sid":""}],"Version":"2012-10-17"},"Path":"/","Policies":[{"PolicyDo>
|                                                                              | ,"ec2:DeleteVpcEndpoints","ec2:DescribeAvailabilityZones","ec2:DescribeIamInstanceProfileAssociations","ec2:DescribeInstanceStatus","ec2:DescribeInstances","ec2:DescribeInternetGateways",">
|                                                                              | }},"Effect":"Allow","Resource":["arn:${AWS::Partition}:iam::*:role/aws-service-role/spot.amazonaws.com/AWSServiceRoleForEC2Spot"]}],"Version":"2012-10-17"},"PolicyName":"${AWS::StackName}->
|                                                                              | ccess"}],"Version":"2012-10-17"}},"Type":"AWS::S3::BucketPolicy"}}}                                           

Note: From the example query result provided above, we previously encountered an error for the stack named databricks-workspace-stack-8f3fd. However, it is now rendering perfectly without any issues.

@misraved misraved merged commit c722b7d into main Mar 14, 2024
1 check passed
@misraved misraved deleted the issue-1954 branch March 14, 2024 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Encountered errors while running AWS cloudformation query to list the stacks
4 participants