service.go 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. // THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
  2. package ssm
  3. import (
  4. "github.com/aws/aws-sdk-go/aws"
  5. "github.com/aws/aws-sdk-go/aws/client"
  6. "github.com/aws/aws-sdk-go/aws/client/metadata"
  7. "github.com/aws/aws-sdk-go/aws/request"
  8. "github.com/aws/aws-sdk-go/aws/signer/v4"
  9. "github.com/aws/aws-sdk-go/private/protocol/jsonrpc"
  10. )
  11. // This is the Amazon EC2 Simple Systems Manager (SSM) API Reference. SSM enables
  12. // you to remotely manage the configuration of your Amazon EC2 instances, virtual
  13. // machines (VMs), or servers in your on-premises environment or in an environment
  14. // provided by other cloud providers using scripts, commands, or the Amazon
  15. // EC2 console. SSM includes an on-demand solution called Amazon EC2 Run Command
  16. // and a lightweight instance configuration solution called SSM Config.
  17. //
  18. // This references is intended to be used with the EC2 Run Command User Guide
  19. // for Linux (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/execute-remote-commands.html)
  20. // or Windows (http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/execute-remote-commands.html).
  21. //
  22. // You must register your on-premises servers and VMs through an activation
  23. // process before you can configure them using Run Command. Registered servers
  24. // and VMs are called managed instances. For more information, see Setting Up
  25. // Run Command On Managed Instances (On-Premises Servers and VMs) on Linux (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/managed-instances.html)
  26. // or Setting Up Run Command On Managed Instances (On-Premises Servers and VMs)
  27. // on Windows (http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/managed-instances.html).
  28. //
  29. // Run Command
  30. //
  31. // Run Command provides an on-demand experience for executing commands. You
  32. // can use pre-defined SSM documents to perform the actions listed later in
  33. // this section, or you can create your own documents. With these documents,
  34. // you can remotely configure your instances by sending commands using the Commands
  35. // page in the Amazon EC2 console (http://console.aws.amazon.com/ec2/), AWS
  36. // Tools for Windows PowerShell (http://docs.aws.amazon.com/powershell/latest/reference/items/Amazon_Simple_Systems_Management_cmdlets.html),
  37. // the AWS CLI (http://docs.aws.amazon.com/cli/latest/reference/ssm/index.html),
  38. // or AWS SDKs.
  39. //
  40. // Run Command reports the status of the command execution for each instance
  41. // targeted by a command. You can also audit the command execution to understand
  42. // who executed commands, when, and what changes were made. By switching between
  43. // different SSM documents, you can quickly configure your instances with different
  44. // types of commands. To get started with Run Command, verify that your environment
  45. // meets the prerequisites for remotely running commands on EC2 instances (Linux
  46. // (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/remote-commands-prereq.html)
  47. // or Windows (http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/remote-commands-prereq.html)).
  48. //
  49. // SSM Config
  50. //
  51. // SSM Config is a lightweight instance configuration solution. SSM Config
  52. // is currently only available for Windows instances. With SSM Config, you can
  53. // specify a setup configuration for your instances. SSM Config is similar to
  54. // EC2 User Data, which is another way of running one-time scripts or applying
  55. // settings during instance launch. SSM Config is an extension of this capability.
  56. // Using SSM documents, you can specify which actions the system should perform
  57. // on your instances, including which applications to install, which AWS Directory
  58. // Service directory to join, which Microsoft PowerShell modules to install,
  59. // etc. If an instance is missing one or more of these configurations, the system
  60. // makes those changes. By default, the system checks every five minutes to
  61. // see if there is a new configuration to apply as defined in a new SSM document.
  62. // If so, the system updates the instances accordingly. In this way, you can
  63. // remotely maintain a consistent configuration baseline on your instances.
  64. // SSM Config is available using the AWS CLI or the AWS Tools for Windows PowerShell.
  65. // For more information, see Managing Windows Instance Configuration (http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2-configuration-manage.html).
  66. //
  67. // SSM Config and Run Command include the following pre-defined documents.
  68. //
  69. // Linux
  70. //
  71. // AWS-RunShellScript to run shell scripts
  72. //
  73. // AWS-UpdateSSMAgent to update the Amazon SSM agent
  74. //
  75. // Windows
  76. //
  77. // AWS-JoinDirectoryServiceDomain to join an AWS Directory
  78. //
  79. // AWS-RunPowerShellScript to run PowerShell commands or scripts
  80. //
  81. // AWS-UpdateEC2Config to update the EC2Config service
  82. //
  83. // AWS-ConfigureWindowsUpdate to configure Windows Update settings
  84. //
  85. // AWS-InstallApplication to install, repair, or uninstall software using
  86. // an MSI package
  87. //
  88. // AWS-InstallPowerShellModule to install PowerShell modules
  89. //
  90. // AWS-ConfigureCloudWatch to configure Amazon CloudWatch Logs to monitor
  91. // applications and systems
  92. //
  93. // AWS-ListWindowsInventory to collect information about an EC2 instance
  94. // running in Windows.
  95. //
  96. // AWS-FindWindowsUpdates to scan an instance and determines which updates
  97. // are missing.
  98. //
  99. // AWS-InstallMissingWindowsUpdates to install missing updates on your EC2
  100. // instance.
  101. //
  102. // AWS-InstallSpecificWindowsUpdates to install one or more specific updates.
  103. //
  104. // The commands or scripts specified in SSM documents run with administrative
  105. // privilege on your instances because the Amazon SSM agent runs as root on
  106. // Linux and the EC2Config service runs in the Local System account on Windows.
  107. // If a user has permission to execute any of the pre-defined SSM documents
  108. // (any document that begins with AWS-*) then that user also has administrator
  109. // access to the instance. Delegate access to Run Command and SSM Config judiciously.
  110. // This becomes extremely important if you create your own SSM documents. Amazon
  111. // Web Services does not provide guidance about how to create secure SSM documents.
  112. // You create SSM documents and delegate access to Run Command at your own risk.
  113. // As a security best practice, we recommend that you assign access to "AWS-*"
  114. // documents, especially the AWS-RunShellScript document on Linux and the AWS-RunPowerShellScript
  115. // document on Windows, to trusted administrators only. You can create SSM documents
  116. // for specific tasks and delegate access to non-administrators.
  117. //
  118. // For information about creating and sharing SSM documents, see the following
  119. // topics in the SSM User Guide:
  120. //
  121. // Creating SSM Documents (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-ssm-doc.html)
  122. // and Sharing SSM Documents (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ssm-sharing.html)
  123. // (Linux)
  124. //
  125. // Creating SSM Documents (http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/create-ssm-doc.html)
  126. // and Sharing SSM Documents (http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ssm-sharing.html)
  127. // (Windows)
  128. //The service client's operations are safe to be used concurrently.
  129. // It is not safe to mutate any of the client's properties though.
  130. type SSM struct {
  131. *client.Client
  132. }
  133. // Used for custom client initialization logic
  134. var initClient func(*client.Client)
  135. // Used for custom request initialization logic
  136. var initRequest func(*request.Request)
  137. // A ServiceName is the name of the service the client will make API calls to.
  138. const ServiceName = "ssm"
  139. // New creates a new instance of the SSM client with a session.
  140. // If additional configuration is needed for the client instance use the optional
  141. // aws.Config parameter to add your extra config.
  142. //
  143. // Example:
  144. // // Create a SSM client from just a session.
  145. // svc := ssm.New(mySession)
  146. //
  147. // // Create a SSM client with additional configuration
  148. // svc := ssm.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  149. func New(p client.ConfigProvider, cfgs ...*aws.Config) *SSM {
  150. c := p.ClientConfig(ServiceName, cfgs...)
  151. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  152. }
  153. // newClient creates, initializes and returns a new service client instance.
  154. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *SSM {
  155. svc := &SSM{
  156. Client: client.New(
  157. cfg,
  158. metadata.ClientInfo{
  159. ServiceName: ServiceName,
  160. SigningRegion: signingRegion,
  161. Endpoint: endpoint,
  162. APIVersion: "2014-11-06",
  163. JSONVersion: "1.1",
  164. TargetPrefix: "AmazonSSM",
  165. },
  166. handlers,
  167. ),
  168. }
  169. // Handlers
  170. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  171. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  172. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  173. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  174. svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
  175. // Run custom client initialization if present
  176. if initClient != nil {
  177. initClient(svc.Client)
  178. }
  179. return svc
  180. }
  181. // newRequest creates a new request for a SSM operation and runs any
  182. // custom request initialization.
  183. func (c *SSM) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  184. req := c.NewRequest(op, params, data)
  185. // Run custom request initialization if present
  186. if initRequest != nil {
  187. initRequest(req)
  188. }
  189. return req
  190. }