aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Anshul Sharma <sharmaanshul2102@gmail.com> 2019-07-04 00:44:31 +0530
committerGravatar Miek Gieben <miek@miek.nl> 2019-07-03 20:14:31 +0100
commit2bd77d0823309c282197256cf9b3d8274578811d (patch)
tree65118e41ee74bcf798a976718599a5f3e449c55d
parentf5fe98395e2777907cdbfee08d37f12b4c1931c7 (diff)
downloadcoredns-2bd77d0823309c282197256cf9b3d8274578811d.tar.gz
coredns-2bd77d0823309c282197256cf9b3d8274578811d.tar.zst
coredns-2bd77d0823309c282197256cf9b3d8274578811d.zip
Fix multiple credentials in route53 (#2859)
-rw-r--r--plugin/route53/setup.go59
1 files changed, 29 insertions, 30 deletions
diff --git a/plugin/route53/setup.go b/plugin/route53/setup.go
index adc2b3e00..6eb165863 100644
--- a/plugin/route53/setup.go
+++ b/plugin/route53/setup.go
@@ -35,21 +35,22 @@ func init() {
}
func setup(c *caddy.Controller, f func(*credentials.Credentials) route53iface.Route53API) error {
- keyPairs := map[string]struct{}{}
- keys := map[string][]string{}
+ for c.Next() {
+ keyPairs := map[string]struct{}{}
+ keys := map[string][]string{}
- // Route53 plugin attempts to find AWS credentials by using ChainCredentials.
- // And the order of that provider chain is as follows:
- // Static AWS keys -> Environment Variables -> Credentials file -> IAM role
- // With that said, even though a user doesn't define any credentials in
- // Corefile, we should still attempt to read the default credentials file,
- // ~/.aws/credentials with the default profile.
- sharedProvider := &credentials.SharedCredentialsProvider{}
- var providers []credentials.Provider
- var fall fall.F
+ // Route53 plugin attempts to find AWS credentials by using ChainCredentials.
+ // And the order of that provider chain is as follows:
+ // Static AWS keys -> Environment Variables -> Credentials file -> IAM role
+ // With that said, even though a user doesn't define any credentials in
+ // Corefile, we should still attempt to read the default credentials file,
+ // ~/.aws/credentials with the default profile.
+ sharedProvider := &credentials.SharedCredentialsProvider{}
+ var providers []credentials.Provider
+ var fall fall.F
+
+ up := upstream.New()
- up := upstream.New()
- for c.Next() {
args := c.RemainingArgs()
for i := 0; i < len(args); i++ {
@@ -99,23 +100,21 @@ func setup(c *caddy.Controller, f func(*credentials.Credentials) route53iface.Ro
return c.Errf("unknown property '%s'", c.Val())
}
}
+ providers = append(providers, &credentials.EnvProvider{}, sharedProvider)
+ client := f(credentials.NewChainCredentials(providers))
+ ctx := context.Background()
+ h, err := New(ctx, client, keys, up)
+ if err != nil {
+ return c.Errf("failed to create Route53 plugin: %v", err)
+ }
+ h.Fall = fall
+ if err := h.Run(ctx); err != nil {
+ return c.Errf("failed to initialize Route53 plugin: %v", err)
+ }
+ dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
+ h.Next = next
+ return h
+ })
}
- providers = append(providers, &credentials.EnvProvider{}, sharedProvider)
-
- client := f(credentials.NewChainCredentials(providers))
- ctx := context.Background()
- h, err := New(ctx, client, keys, up)
- if err != nil {
- return c.Errf("failed to create Route53 plugin: %v", err)
- }
- h.Fall = fall
- if err := h.Run(ctx); err != nil {
- return c.Errf("failed to initialize Route53 plugin: %v", err)
- }
- dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
- h.Next = next
- return h
- })
-
return nil
}