service.go 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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. // Amazon EC2 Simple Systems Manager (SSM) enables you to remotely manage the
  12. // configuration of your Amazon EC2 instances, virtual machines (VMs), or servers
  13. // in your on-premises environment or in an environment provided by other cloud
  14. // providers using scripts, commands, or the Amazon EC2 console. SSM includes
  15. // an on-demand solution called Amazon EC2 Run Command and a lightweight instance
  16. // 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 is
  52. // 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
  100. // EC2 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
  106. // on Linux and the EC2Config service runs in the Local System account on
  107. // Windows. If a user has permission to execute any of the pre-defined SSM
  108. // documents (any document that begins with AWS-*) then that user also has
  109. // administrator access to the instance. Delegate access to Run Command and
  110. // SSM Config judiciously. This becomes extremely important if you create
  111. // your own SSM documents. Amazon Web Services does not provide guidance
  112. // about how to create secure SSM documents. You create SSM documents and
  113. // delegate access to Run Command at your own risk. As a security best practice,
  114. // we recommend that you assign access to "AWS-*" documents, especially the
  115. // AWS-RunShellScript document on Linux and the AWS-RunPowerShellScript document
  116. // on Windows, to trusted administrators only. You can create SSM documents
  117. // for specific tasks and delegate access to non-administrators.
  118. //
  119. // For information about creating and sharing SSM documents, see the following
  120. // topics in the SSM User Guide:
  121. //
  122. // * Creating SSM Documents (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/create-ssm-doc.html)
  123. // and * Sharing SSM Documents (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ssm-sharing.html)
  124. // (Linux)
  125. //
  126. // * Creating SSM Documents (http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/create-ssm-doc.html)
  127. // and * Sharing SSM Documents (http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ssm-sharing.html)
  128. // (Windows)
  129. //The service client's operations are safe to be used concurrently.
  130. // It is not safe to mutate any of the client's properties though.
  131. type SSM struct {
  132. *client.Client
  133. }
  134. // Used for custom client initialization logic
  135. var initClient func(*client.Client)
  136. // Used for custom request initialization logic
  137. var initRequest func(*request.Request)
  138. // A ServiceName is the name of the service the client will make API calls to.
  139. const ServiceName = "ssm"
  140. // New creates a new instance of the SSM client with a session.
  141. // If additional configuration is needed for the client instance use the optional
  142. // aws.Config parameter to add your extra config.
  143. //
  144. // Example:
  145. // // Create a SSM client from just a session.
  146. // svc := ssm.New(mySession)
  147. //
  148. // // Create a SSM client with additional configuration
  149. // svc := ssm.New(mySession, aws.NewConfig().WithRegion("us-west-2"))
  150. func New(p client.ConfigProvider, cfgs ...*aws.Config) *SSM {
  151. c := p.ClientConfig(ServiceName, cfgs...)
  152. return newClient(*c.Config, c.Handlers, c.Endpoint, c.SigningRegion)
  153. }
  154. // newClient creates, initializes and returns a new service client instance.
  155. func newClient(cfg aws.Config, handlers request.Handlers, endpoint, signingRegion string) *SSM {
  156. svc := &SSM{
  157. Client: client.New(
  158. cfg,
  159. metadata.ClientInfo{
  160. ServiceName: ServiceName,
  161. SigningRegion: signingRegion,
  162. Endpoint: endpoint,
  163. APIVersion: "2014-11-06",
  164. JSONVersion: "1.1",
  165. TargetPrefix: "AmazonSSM",
  166. },
  167. handlers,
  168. ),
  169. }
  170. // Handlers
  171. svc.Handlers.Sign.PushBackNamed(v4.SignRequestHandler)
  172. svc.Handlers.Build.PushBackNamed(jsonrpc.BuildHandler)
  173. svc.Handlers.Unmarshal.PushBackNamed(jsonrpc.UnmarshalHandler)
  174. svc.Handlers.UnmarshalMeta.PushBackNamed(jsonrpc.UnmarshalMetaHandler)
  175. svc.Handlers.UnmarshalError.PushBackNamed(jsonrpc.UnmarshalErrorHandler)
  176. // Run custom client initialization if present
  177. if initClient != nil {
  178. initClient(svc.Client)
  179. }
  180. return svc
  181. }
  182. // newRequest creates a new request for a SSM operation and runs any
  183. // custom request initialization.
  184. func (c *SSM) newRequest(op *request.Operation, params, data interface{}) *request.Request {
  185. req := c.NewRequest(op, params, data)
  186. // Run custom request initialization if present
  187. if initRequest != nil {
  188. initRequest(req)
  189. }
  190. return req
  191. }