mirror of https://github.com/docker/compose.git
Allow user to customize Roles / ManagedPolicy
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
8182c98abf
commit
f74cc8f0aa
|
@ -440,15 +440,26 @@ func createTaskExecutionRole(service types.ServiceConfig, err error, definition
|
||||||
PolicyDocument: policy,
|
PolicyDocument: policy,
|
||||||
PolicyName: fmt.Sprintf("%sGrantAccessToSecrets", service.Name),
|
PolicyName: fmt.Sprintf("%sGrantAccessToSecrets", service.Name),
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if roles, ok := service.Extensions[compose.ExtensionRole]; ok {
|
||||||
|
rolePolicies = append(rolePolicies, iam.Role_Policy{
|
||||||
|
PolicyDocument: roles,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
managedPolicies := []string{
|
||||||
|
ECSTaskExecutionPolicy,
|
||||||
|
ECRReadOnlyPolicy,
|
||||||
|
}
|
||||||
|
if v, ok := service.Extensions[compose.ExtensionManagedPolicies]; ok {
|
||||||
|
for _, s := range v.([]interface{}) {
|
||||||
|
managedPolicies = append(managedPolicies, s.(string))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
template.Resources[taskExecutionRole] = &iam.Role{
|
template.Resources[taskExecutionRole] = &iam.Role{
|
||||||
AssumeRolePolicyDocument: assumeRolePolicyDocument,
|
AssumeRolePolicyDocument: assumeRolePolicyDocument,
|
||||||
Policies: rolePolicies,
|
Policies: rolePolicies,
|
||||||
ManagedPolicyArns: []string{
|
ManagedPolicyArns: managedPolicies,
|
||||||
ECSTaskExecutionPolicy,
|
|
||||||
ECRReadOnlyPolicy,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
return taskExecutionRole, nil
|
return taskExecutionRole, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ var assumeRolePolicyDocument = PolicyDocument{
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// could alternatively depend on https://github.com/kubernetes-sigs/cluster-api-provider-aws/blob/master/pkg/cloud/services/iam/types.go#L52
|
// could alternatively depend on https://github.com/kubernetes-sigs/cluster-api-provider-aws/blob/master/cmd/clusterawsadm/api/iam/v1alpha1/types.go
|
||||||
type PolicyDocument struct {
|
type PolicyDocument struct {
|
||||||
Version string `json:",omitempty"`
|
Version string `json:",omitempty"`
|
||||||
Statement []PolicyStatement `json:",omitempty"`
|
Statement []PolicyStatement `json:",omitempty"`
|
||||||
|
|
|
@ -10,4 +10,6 @@ const (
|
||||||
ExtensionMinPercent = "x-aws-min_percent"
|
ExtensionMinPercent = "x-aws-min_percent"
|
||||||
ExtensionMaxPercent = "x-aws-max_percent"
|
ExtensionMaxPercent = "x-aws-max_percent"
|
||||||
ExtensionRetention = "x-aws-logs_retention"
|
ExtensionRetention = "x-aws-logs_retention"
|
||||||
|
ExtensionRole = "x-aws-role"
|
||||||
|
ExtensionManagedPolicies = "x-aws-policies"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue