Creates a document. :param content: The content of the document. :param name: The name of the document.
(self, content, name)
| 31 | |
| 32 | # snippet-start:[python.example_code.ssm.CreateDocument] |
| 33 | def create(self, content, name): |
| 34 | """ |
| 35 | Creates a document. |
| 36 | |
| 37 | :param content: The content of the document. |
| 38 | :param name: The name of the document. |
| 39 | """ |
| 40 | try: |
| 41 | self.ssm_client.create_document( |
| 42 | Name=name, Content=content, DocumentType="Command" |
| 43 | ) |
| 44 | self.name = name |
| 45 | except self.ssm_client.exceptions.DocumentAlreadyExists: |
| 46 | print(f"Document {name} already exists.") |
| 47 | self.name = name |
| 48 | except ClientError as err: |
| 49 | logger.error( |
| 50 | "Couldn't create %s. Here's why: %s: %s", |
| 51 | name, |
| 52 | err.response["Error"]["Code"], |
| 53 | err.response["Error"]["Message"], |
| 54 | ) |
| 55 | raise |
| 56 | |
| 57 | # snippet-end:[python.example_code.ssm.CreateDocument] |
| 58 |