This documentation is for Version 1 of the Amazon CLI only. For documentation related to Version 2 of the Amazon CLI, see the Version 2 User Guide.
Amazon IoT 1-Click Projects examples using Amazon CLI
The following code examples show you how to perform actions and implement common scenarios by using the Amazon Command Line Interface with Amazon IoT 1-Click Projects.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Topics
Actions
The following code example shows how to use associate-device-with-placement
.
- Amazon CLI
-
To associate an Amazon IoT 1-Click device with an existing placement
The following
associate-device-with-placement
example associates the specified Amazon IoT 1-Click device with an existing placement.aws iot1click-projects associate-device-with-placement \ --project-name
AnytownDumpsters
\ --placement-namecustomer217
\ --device-template-nameempty-dumpster-request
\ --device-idG030PM0123456789
This command produces no output.
For more information, see Using Amazon IoT 1-Click with the Amazon CLI
in the Amazon IoT 1-Click Developer Guide. -
For API details, see AssociateDeviceWithPlacement
in Amazon CLI Command Reference.
-
The following code example shows how to use create-placement
.
- Amazon CLI
-
To create an Amazon IoT 1-Click placement for a project
The following
create-placement
example create an Amazon IoT 1-Click placement for the specified project.aws iot1click-projects create-placement \ --project-name
AnytownDumpsters
\ --placement-namecustomer217
\ --attributes "{"location": "123Any
Street
Anytown,
USA
10001", "phone": "123-456-7890"}"This command produces no output.
For more information, see Using Amazon IoT 1-Click with the Amazon CLI
in the Amazon IoT 1-Click Developer Guide. -
For API details, see CreatePlacement
in Amazon CLI Command Reference.
-
The following code example shows how to use create-project
.
- Amazon CLI
-
To create an Amazon IoT 1-Click project for zero or more placements
The following
create-project
example creates an Amazon IoT 1-Click project for a placement.aws iot1click-projects create-project --cli-input-json file://create-project.json
Contents of
create-project.json
:{ "projectName": "AnytownDumpsters", "description": "All dumpsters in the Anytown region.", "placementTemplate": { "defaultAttributes": { "City" : "Anytown" }, "deviceTemplates": { "empty-dumpster-request" : { "deviceType": "button" } } } }
This command produces no output.
For more information, see Using Amazon IoT 1-Click with the Amazon CLI
in the Amazon IoT 1-Click Developer Guide. -
For API details, see CreateProject
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-placement
.
- Amazon CLI
-
To delete a placement from a project
The following
delete-placement
example deletes the specified placement from a project.aws iot1click-projects delete-placement \ --project-name
AnytownDumpsters
\ --placement-namecustomer217
This command produces no output.
For more information, see Using Amazon IoT 1-Click with the Amazon CLI
in the Amazon IoT 1-Click Developer Guide. -
For API details, see DeletePlacement
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-project
.
- Amazon CLI
-
To delete a project from your Amazon account
The following
delete-project
example deletes the specified project from your Amazon account.aws iot1click-projects delete-project \ --project-name
AnytownDumpsters
This command produces no output.
For more information, see Using Amazon IoT 1-Click with the Amazon CLI
in the Amazon IoT 1-Click Developer Guide. -
For API details, see DeleteProject
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-placement
.
- Amazon CLI
-
To describe a placement for a project
The following
describe-placement
example describes a placement for the specified project.aws iot1click-projects describe-placement \ --project-name
AnytownDumpsters
\ --placement-namecustomer217
Output:
{ "placement": { "projectName": "AnytownDumpsters", "placementName": "customer217", "attributes": { "phone": "123-555-0110", "location": "123 Any Street Anytown, USA 10001" }, "createdDate": 1563488454, "updatedDate": 1563488454 } }
For more information, see Using Amazon IoT 1-Click with the Amazon CLI
in the Amazon IoT 1-Click Developer Guide. -
For API details, see DescribePlacement
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-project
.
- Amazon CLI
-
To describe an Amazon IoT 1-Click project
The following
describe-project
example describes the specified Amazon IoT 1-Click project.aws iot1click-projects describe-project \ --project-name
AnytownDumpsters
Output:
{ "project": { "arn": "arn:aws:iot1click:us-west-2:012345678901:projects/AnytownDumpsters", "projectName": "AnytownDumpsters", "description": "All dumpsters in the Anytown region.", "createdDate": 1563483100, "updatedDate": 1563483100, "placementTemplate": { "defaultAttributes": { "City": "Anytown" }, "deviceTemplates": { "empty-dumpster-request": { "deviceType": "button", "callbackOverrides": {} } } }, "tags": {} } }
For more information, see Using Amazon IoT 1-Click with the Amazon CLI
in the Amazon IoT 1-Click Developer Guide. -
For API details, see DescribeProject
in Amazon CLI Command Reference.
-
The following code example shows how to use disassociate-device-from-placement
.
- Amazon CLI
-
To disassociate a device from a placement
The following
disassociate-device-from-placement
example disassociates the specified device from a placement.aws iot1click-projects disassociate-device-from-placement \ --project-name
AnytownDumpsters
\ --placement-namecustomer217
\ --device-template-nameempty-dumpster-request
This command produces no output.
For more information, see Using Amazon IoT 1-Click with the Amazon CLI
in the Amazon IoT 1-Click Developer Guide. -
For API details, see DisassociateDeviceFromPlacement
in Amazon CLI Command Reference.
-
The following code example shows how to use get-devices-in-placement
.
- Amazon CLI
-
To list all devices in a placement contained in a project
The following
get-devices-in-placement
example lists all devices in a the specified placement contained in the specified project.aws iot1click-projects get-devices-in-placement \ --project-name
AnytownDumpsters
\ --placement-namecustomer217
Output:
{ "devices": { "empty-dumpster-request": "G030PM0123456789" } }
For more information, see Using Amazon IoT 1-Click with the Amazon CLI
in the Amazon IoT 1-Click Developer Guide. -
For API details, see GetDevicesInPlacement
in Amazon CLI Command Reference.
-
The following code example shows how to use list-placements
.
- Amazon CLI
-
To list all Amazon IoT 1-Click placements for a project
The following
list-placements
example lists all Amazon IoT 1-Click placements for the specified project.aws iot1click-projects list-placements \ --project-name
AnytownDumpsters
Output:
{ "placements": [ { "projectName": "AnytownDumpsters", "placementName": "customer217", "createdDate": 1563488454, "updatedDate": 1563488454 } ] }
For more information, see Using Amazon IoT 1-Click with the Amazon CLI
in the Amazon IoT 1-Click Developer Guide. -
For API details, see ListPlacements
in Amazon CLI Command Reference.
-
The following code example shows how to use list-projects
.
- Amazon CLI
-
To list all Amazon IoT 1-Click projects
The following
list-projects
example list all Amazon IoT 1-Click projects in your account.aws iot1click-projects list-projects
Output:
{ "projects": [ { "arn": "arn:aws:iot1click:us-west-2:012345678901:projects/AnytownDumpsters", "projectName": "AnytownDumpsters", "createdDate": 1563483100, "updatedDate": 1563483100, "tags": {} } ] }
For more information, see Using Amazon IoT 1-Click with the Amazon CLI
in the Amazon IoT 1-Click Developer Guide. -
For API details, see ListProjects
in Amazon CLI Command Reference.
-
The following code example shows how to use list-tags-for-resource
.
- Amazon CLI
-
To list the tags for a project resource
The following
list-tags-for-resource
example list the tags for the specified project resource.aws iot1click-projects list-tags-for-resource \ --resource-arn
"arn:aws:iot1click:us-west-2:123456789012:projects/AnytownDumpsters"
Output:
{ "tags": { "Manager": "Li Juan", "Account": "45215" } }
For more information, see Using Amazon IoT 1-Click with the Amazon CLI
in the Amazon IoT 1-Click Developer Guide. -
For API details, see ListTagsForResource
in Amazon CLI Command Reference.
-
The following code example shows how to use tag-resource
.
- Amazon CLI
-
To add tags to a project resource
The following
tag-resource
example adds two tags to the specified project resource.aws iot1click-projects tag-resource \ --cli-input-json
file://devices-tag-resource.json
Contents of
devices-tag-resource.json
:{ "resourceArn": "arn:aws:iot1click:us-west-2:123456789012:projects/AnytownDumpsters", "tags": { "Account": "45215", "Manager": "Li Juan" } }
This command produces no output.
For more information, see Using Amazon IoT 1-Click with the Amazon CLI
in the Amazon IoT 1-Click Developer Guide. -
For API details, see TagResource
in Amazon CLI Command Reference.
-
The following code example shows how to use untag-resource
.
- Amazon CLI
-
To remove tags from a project resource
The following
untag-resource
example removes the tag with the key nameManager
from the specified project.aws iot1click-projects untag-resource \ --resource-arn
"arn:aws:iot1click:us-west-2:123456789012:projects/AnytownDumpsters"
\ --tag-keys"Manager"
This command produces no output.
For more information, see Using Amazon IoT 1-Click with the Amazon CLI
in the Amazon IoT 1-Click Developer Guide. -
For API details, see UntagResource
in Amazon CLI Command Reference.
-
The following code example shows how to use update-placement
.
- Amazon CLI
-
To update the "attributes" key-value pairs of a placement
The following
update-placement
example update the "attributes" key-value pairs of a placement.aws iot1click-projects update-placement \ --cli-input-json
file://update-placement.json
Contents of
update-placement.json
:{ "projectName": "AnytownDumpsters", "placementName": "customer217", "attributes": { "phone": "123-456-7890", "location": "123 Any Street Anytown, USA 10001" } }
This command produces no output.
For more information, see Using Amazon IoT 1-Click with the Amazon CLI
in the Amazon IoT 1-Click Developer Guide. -
For API details, see UpdatePlacement
in Amazon CLI Command Reference.
-
The following code example shows how to use update-project
.
- Amazon CLI
-
To update settings for a project
The following
update-project
example updates the description for a project.aws iot1click-projects update-project \ --project-name
AnytownDumpsters
\ --description"All dumpsters (yard waste, recycling, garbage) in the Anytown region."
This command produces no output.
For more information, see Using Amazon IoT 1-Click with the Amazon CLI
in the Amazon IoT 1-Click Developer Guide. -
For API details, see UpdateProject
in Amazon CLI Command Reference.
-