Question -- awscc_quicksight_data_set (Terraform)

I am trying to create a quicksight data_set using terraform. I can create using provisioner(local-exec) using the aws cli. However, it will be some work to make it idempotent. Creating is easy but destroying will require some scripting. Before I start working on the scripting part, I would like to explore if anyone has used

`awscc_quicksight_data_set`

If yes, can you please share the starter’s code.

Thanks !

1 Like

Can you explorer official documentation for Terraform - Terraform Registry

I used boto3 and custom python script to create data sets and if you need help, let me know. Never tried Terraform but will explorer on AWS Cloud Control Provider.

Regards - San

1 Like

@Sanjeeb2022 I have tried going thru the documentation and will continue to dig in further as I think that Terraform may be cleaner. However, I would appreciate if you could send me a sample code to create data sets using python.

Thanks !

@larry : Please find sample skeleton code below. If you are looking for complete working code, let me know i can spend sometime and develop for you.

However you need to configure a local development environment ( boto3 and python) or use cloud shell from AWS console to develop as well.

import sys
import boto3
import json

Ensure you set up aws cli and python

configure aws credentials as well

account_id=<<<<-Give your aws account >>>
physicial_table_id=<<<<-Give any table id but it has to be unique>>
Name=<<<-Name of the data set you want to give>>
logical_file=<<<-Give the complete local path where you have kept your logical json file and file name>>
physical_file=<<<-Give the complete local path where you have kept your physical json file and file name>>
physical_table_map=json.load(physical_file)
logical_table_map=json.load(logical_file)

principal_val= <<< -Give the arn of the user who has the access and permission to create data sets in quicksight->>

Regards - San
quicksight = boto3.client(“quicksight”)

new_data_set = quicksight.create_data_set(
AwsAccountId = account_id,
DataSetId = physicial_table_id,
Name = Name,
PhysicalTableMap = physical_table_map,
LogicalTableMap = logical_table_map,
ImportMode = ‘DIRECT_QUERY’,
Permissions = [
{
‘Principal’: principal_val,
‘Actions’: [“quicksight:DescribeDataSet”,“quicksight:DescribeDataSetPermissions”,“quicksight:PassDataSet”,“quicksight:DescribeIngestion”,“quicksight:ListIngestions”,“quicksight:UpdateDataSet”,“quicksight:DeleteDataSet”,“quicksight:CreateIngestion”,“quicksight:CancelIngestion”,“quicksight:UpdateDataSetPermissions”]
}

    ]
)

print(new_data_set)

1 Like

Hi @larry
Please refer the below links for the list of AWS CLI commands for QuickSIght.

https://docs.aws.amazon.com/cli/latest/reference/quicksight/index.html
https://docs.aws.amazon.com/cli/latest/reference/quicksight/create-data-set.html

This should help you with examples and code skeleton.

Thanks,
Naveen

1 Like

@namysore My original question was only limited to Terraform. I wish create a quicksight data_set using Terraform(ONLY). No other solution is really going to address my problem.