iam.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. Copyright 2020 Docker, Inc.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package ecs
  14. const (
  15. ecsTaskExecutionPolicy = "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"
  16. ecrReadOnlyPolicy = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly"
  17. actionGetSecretValue = "secretsmanager:GetSecretValue"
  18. actionGetParameters = "ssm:GetParameters"
  19. actionDecrypt = "kms:Decrypt"
  20. )
  21. var assumeRolePolicyDocument = PolicyDocument{
  22. Version: "2012-10-17", // https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_version.html
  23. Statement: []PolicyStatement{
  24. {
  25. Effect: "Allow",
  26. Principal: PolicyPrincipal{
  27. Service: "ecs-tasks.amazonaws.com",
  28. },
  29. Action: []string{"sts:AssumeRole"},
  30. },
  31. },
  32. }
  33. // PolicyDocument describes an IAM policy document
  34. // could alternatively depend on https://github.com/kubernetes-sigs/cluster-api-provider-aws/blob/master/cmd/clusterawsadm/api/iam/v1alpha1/types.go
  35. type PolicyDocument struct {
  36. Version string `json:",omitempty"`
  37. Statement []PolicyStatement `json:",omitempty"`
  38. }
  39. // PolicyStatement describes an IAM policy statement
  40. type PolicyStatement struct {
  41. Effect string `json:",omitempty"`
  42. Action []string `json:",omitempty"`
  43. Principal PolicyPrincipal `json:",omitempty"`
  44. Resource []string `json:",omitempty"`
  45. }
  46. // PolicyPrincipal describes an IAM policy principal
  47. type PolicyPrincipal struct {
  48. Service string `json:",omitempty"`
  49. }