How to use aws-cli commands inside Boto3

0 votes
Hi,

I need to describe users from AWS Appstream Stacks. Below is the command to describe users

#aws appstream describe-user-stack-associations --stack-name <examplestack> --region <regionname>

but i need to use aws cli commands inside Boto3(Python). How to do?
Sep 21, 2020 in DevOps on Cloud by Lakshminarayanan
• 1,360 points
925 views

1 answer to this question.

0 votes

Hi@Lakshminarayanan,

I am not able to understand the use case. You are trying to use aws cli command in boto3. But you can do all the tasks using boto3 syntax. For example, You are using AWS appstream command in AWS cli. You can do the same in boto3 also as shown below.

import boto3
client = boto3.client('appstream')

These are the available methods:
associate_fleet()
batch_associate_user_stack()
batch_disassociate_user_stack()
can_paginate()
copy_image()
create_directory_config()
create_fleet()
create_image_builder()
create_image_builder_streaming_url()
create_stack()
create_streaming_url()
create_usage_report_subscription()
create_user()
delete_directory_config()
delete_fleet()
delete_image()
delete_image_builder()
delete_image_permissions()
delete_stack()
delete_usage_report_subscription()
delete_user()
describe_directory_configs()
describe_fleets()
describe_image_builders()
describe_image_permissions()
describe_images()
describe_sessions()
describe_stacks()
describe_usage_report_subscriptions()
describe_user_stack_associations()
describe_users()
disable_user()
disassociate_fleet()
enable_user()
expire_session()
generate_presigned_url()
get_paginator()
get_waiter()
list_associated_fleets()
list_associated_stacks()
list_tags_for_resource()
start_fleet()
start_image_builder()
stop_fleet()
stop_image_builder()
tag_resource()
untag_resource()
update_directory_config()
update_fleet()
update_image_permissions()
update_stack()
answered Sep 21, 2020 by MD
• 95,220 points
Hi,

i have tried with below code. But this code doesn't listing users from command line. Kindly check below one,

#!/usr/bin/env python3

import boto3

client = boto3.client('appstream',aws_access_key_id='xxxxxxxxxxxxxxxx',aws_secret_access_key='yyyyyyyy')

session = boto3.Session(region_name='us-west-2', profile_name='exampleaws')

response = client.describe_user_stack_associations(
    StackName='ss',
    UserName='Latchu',
    AuthenticationType='USERPOOL',
#    MaxResults=123,
#    NextToken='string'
)
I trying to list users which are associated with Appstream Stack. I hope you understand my question. i'm trying to listing user details using above code. But no listing, even no error in code.
Thats why i choose AWS-CLI commands inside boto3. I can list use below command, but i can't list users using boto3 code.

#aws appstream describe-user-stack-associations --stack-name ss --region us-west-2

Hi,

But according to me, you can't use aws cli inside boto3. Ok do one thing if you are using aws cli command then use a simple python script. Because if you are using aws command inside boto3 means boto3 script will work as simple python script.

ok sure i will check

Related Questions In DevOps on Cloud

0 votes
1 answer
+1 vote
3 answers
0 votes
2 answers
0 votes
1 answer
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
1,135 views
+2 votes
1 answer
0 votes
1 answer

How to use the pipeline setup and deploy the war file using the ansible,docker and kubernettes

Hi@Venkata, You can create an Ansible-Playbook to deploy ...READ MORE

answered Sep 1, 2020 in DevOps on Cloud by MD
• 95,220 points
201 views
0 votes
1 answer

How to create user and password in Windows EC2 instance using boto3 Script?

Hi, I don't think AWS will allow you ...READ MORE

answered Sep 23, 2020 in DevOps on Cloud by MD
• 95,220 points
223 views