コード例 #1
0
        /// <summary>
        /// Resolves connection and credental parameters and generates a single AWSConnectionParams value.
        /// </summary>
        /// <param name="correlationId">(optional) transaction id to trace execution through call chain.</param>
        /// <returns>AWSConnectionParams value</returns>
        public async Task <AwsConnectionParams> ResolveAsync(string correlationId)
        {
            var result = new AwsConnectionParams();

            var connection = await _connectionResolver.ResolveAsync(correlationId);

            result.Append(connection);

            var credential = await _credentialResolver.LookupAsync(correlationId);

            result.Append(credential);

            // Force ARN parsing
            result.Arn = result.Arn;

            // Perform validation
            var err = result.Validate(correlationId);

            if (err != null)
            {
                throw err;
            }

            return(result);
        }
コード例 #2
0
        public void TestParseArn()
        {
            var connection = new AwsConnectionParams();

            connection.Arn = "arn:aws:lambda:us-east-1:12342342332:function:pip-services3-dummies";
            Assert.Equal("lambda", connection.Service);
            Assert.Equal("us-east-1", connection.Region);
            Assert.Equal("12342342332", connection.Account);
            Assert.Equal("function", connection.ResourceType);
            Assert.Equal("pip-services3-dummies", connection.Resource);

            connection.Arn = "arn:aws:s3:us-east-1:12342342332:pip-services3-dummies";
            Assert.Equal("s3", connection.Service);
            Assert.Equal("us-east-1", connection.Region);
            Assert.Equal("12342342332", connection.Account);
            Assert.Equal(null, connection.ResourceType);
            Assert.Equal("pip-services3-dummies", connection.Resource);

            connection.Arn = "arn:aws:lambda:us-east-1:12342342332:function/pip-services3-dummies";
            Assert.Equal("lambda", connection.Service);
            Assert.Equal("us-east-1", connection.Region);
            Assert.Equal("12342342332", connection.Account);
            Assert.Equal("function", connection.ResourceType);
            Assert.Equal("pip-services3-dummies", connection.Resource);
        }
コード例 #3
0
        public void TestComposeArnWithAnotherCredentialsParamNames()
        {
            var connection = AwsConnectionParams.FromConfig(
                ConfigParams.FromTuples(
                    "connection.service", "lambda",
                    "connection.region", "us-east-1",
                    "connection.account", "12342342332",
                    "connection.resource_type", "function",
                    "connection.resource", "pip-services3-dummies",
                    "credential.client_id", "1234",
                    "credential.client_key", "ABCDEF"
                    )
                );

            Assert.Equal("arn:aws:lambda:us-east-1:12342342332:function:pip-services3-dummies", connection.Arn);
            Assert.Equal("1234", connection.AccessId);
            Assert.Equal("ABCDEF", connection.AccessKey);
        }
        /// <summary>
        /// Retrieves AwsConnectionParams from configuration parameters.
        /// The values are retrieves from "connection" and "credential" sections.
        /// </summary>
        /// <param name="config">configuration parameters</param>
        /// <returns>the generated AwsConnectionParams object.</returns>
        public static AwsConnectionParams FromConfig(ConfigParams config)
        {
            var result = new AwsConnectionParams();

            var credentials = CredentialParams.ManyFromConfig(config);

            foreach (var credential in credentials)
            {
                result.Append(credential);
            }

            var connections = ConnectionParams.ManyFromConfig(config);

            foreach (var connection in connections)
            {
                result.Append(connection);
            }

            return(result);
        }
コード例 #5
0
        public void TestEmptyConnection()
        {
            var connection = new AwsConnectionParams();

            Assert.Equal("arn:aws::::", connection.Arn);
        }