Neil
February 1, 2024, 9:43pm
1
Hello,
Have successfully written CLI commands to export/import QuickSight resources using the “bundle” commands, e.g.
aws quicksight start-asset-bundle-export-job --aws-account-id <id>
–asset-bundle-export-job-id 1234 --resource-arns <arn>
–include-all-dependencies --export-format QUICKSIGHT_JSON
–profile
Am now converting these to use PowerShell Cmdlets, e.g.
Start-QSAssetBundleExportJob -AssetBundleExportJobId 1234
-AwsAccountId -IncludeAllDependency 1
-ResourceArn -ExportFormat QUICKSIGHT_JSON
-ProfileName
For the corresponding “import” cmdlet - “Start-QSAssetBundleImportJob” - I am not sure how to handle the “override” parameters, e.g. “-OverrideParameters_DataSource”. The type is “<AssetBundleImportJobDataSourceOverrideParameters >”.
For the “aws quicksight start-asset-bundle-import-job” equivalent, I have created a JSON file containing the override parameters, and use the “–override-parameters” parameter to point to this JSON file. This is straightforward.
Could someone please point me in the right direction for how to populate a PowerShell parameter to pass to the “<AssetBundleImportJobDataSourceOverrideParameters >” parameter of the “Start-QSAssetBundleImportJob” cmdlet? Can JSON be used in some way?
Many thanks in advance,
Neil
duncan
February 2, 2024, 3:57pm
2
Hey @Neil !
I would check out the docs below:
Neil
February 2, 2024, 6:31pm
3
Hi Duncan,
Thanks for your reply.
Your first link relates to Java. I’m working with PowerShell on Windows.
I’ve made some progress today. If I get it working I will upload the outline of the solution.
Thanks,
Neil
Neil
February 7, 2024, 11:11am
4
Here is an outline solution.
Pre-requisites:
The “AWS.Tools.QuickSight” module is installed.
“$OverrideParametersFilename” is a script parameter which points to a JSON file containing Data Source override parameters in the following format:
{
“DataSources”:[
{
“DataSourceId”:“Id value”,
“DataSourceParameters”:
{
“S3Parameters”:
{
“ManifestFileLocation”:
{
“Bucket”:“Bucket Name”,
“Key”:“Key Name containing name of manifest file”
}
}
}
}]
}
Script code:
Import-Module AWS.Tools.QuickSight
Read JSON file for containing override parameters.
$OverrideParametersFile = Get-Content -Path $OverrideParametersFilename -Raw | Out-String | ConvertFrom-Json
Initialise array.
[Amazon.QuickSight.Model.AssetBundleImportJobDataSourceOverrideParameters ] $DataSourcesOverrideParameters = @()
Loop through each Data Source.
foreach ($DataSource in $OverrideParametersFile.DataSources)
{
$DataSourceOverrideParameters = [Amazon.QuickSight.Model.AssetBundleImportJobDataSourceOverrideParameters]::new()
$DataSourceOverrideParameters.DataSourceId = $DataSource.DataSourceId
$DataSourceOverrideParameters.DataSourceParameters = [Amazon.QuickSight.Model.DataSourceParameters]::new()
$DataSourceOverrideParameters.DataSourceParameters.S3Parameters = [Amazon.QuickSight.Model.S3Parameters]::new()
$DataSourceOverrideParameters.DataSourceParameters.S3Parameters.ManifestFileLocation = [Amazon.QuickSight.Model.ManifestFileLocation]::new()
$DataSourceOverrideParameters.DataSourceParameters.S3Parameters.ManifestFileLocation.Bucket = $DataSource.DataSourceParameters.S3Parameters.ManifestFileLocation.Bucket
$DataSourceOverrideParameters.DataSourceParameters.S3Parameters.ManifestFileLocation.Key = $DataSource.DataSourceParameters.S3Parameters.ManifestFileLocation.Key
$DataSourcesOverrideParameters += $DataSourceOverrideParameters
}
“$DataSourcesOverrideParameters” can then be passed to the “OverrideParameters_DataSource” parameter of the “Start-QSAssetBundleImportJob” cmdlet.
Similar code can be written to populate parameters for the override permissions.
Hope the above will be useful for someone.