Exemple #1
0
        public void WhenInputParameterIsListAndOneElementMatchesThenElementIsFound()
        {
            var resource = new StateFileResourceInstance {
                Attributes = resourceAttributes
            };
            var templateParameter = new Mock <IParameter>();

            templateParameter.Setup(p => p.Name).Returns("PrivateSubnets");
            templateParameter.Setup(p => p.Type).Returns("List<AWS::EC2::Subnet::Id>");
            templateParameter.Setup(p => p.GetCurrentValue()).Returns("subnet-00000000,subnet-11111111");

            var inputVariable = InputVariable.CreateParameter(templateParameter.Object);
            var result        = resource.FindId(inputVariable, false);

            result.Should().HaveCount(2, "there should be 1 property match and 1 array match");
        }
Exemple #2
0
        public void WhenInputParameterIsStringAndAttributeScalarValueMatchesThenElementIsFound()
        {
            var resource = new StateFileResourceInstance {
                Attributes = resourceAttributes
            };
            var templateParameter = new Mock <IParameter>();

            templateParameter.Setup(p => p.Name).Returns("VpcId");
            templateParameter.Setup(p => p.Type).Returns("AWS::EC2::VPC::Id");
            templateParameter.Setup(p => p.GetCurrentValue()).Returns("vpc-00000000");

            var inputVariable = InputVariable.CreateParameter(templateParameter.Object);

            var result = resource.FindId(inputVariable, false);

            result.Should().HaveCount(1).And
            .AllBeOfType <JProperty>("property returned has the element we are looking for as its value");
        }
Exemple #3
0
        public void WhenInputParameterIsStringAndAttributeArrayValueMatchesThenElementIsFound()
        {
            var resource = new StateFileResourceInstance {
                Attributes = resourceAttributes
            };
            var templateParameter = new Mock <IParameter>();

            templateParameter.Setup(p => p.Name).Returns("VpcId");
            templateParameter.Setup(p => p.Type).Returns("AWS::EC2::SecurityGroup::Id");
            templateParameter.Setup(p => p.GetCurrentValue()).Returns("sg-00000000");

            var inputVariable = InputVariable.CreateParameter(templateParameter.Object);

            var result = resource.FindId(inputVariable, false);

            result.Should().HaveCount(1).And
            .AllBeOfType <JArray>("array returned contains the element we are looking for");
        }
Exemple #4
0
        /// <summary>
        /// Gets the value of the property on the target terraform resource referenced by this <c>!GetAtt</c>.
        /// </summary>
        /// <param name="self">Instance of intrinsic.</param>
        /// <param name="template">The template.</param>
        /// <param name="targetResource">The target resource.</param>
        /// <returns>An <see cref="IGetAttTargetEvaluation"/> containing result of the underlying resource visit.</returns>
        public static IGetAttTargetEvaluation GetTargetValue(this GetAttIntrinsic self, ITemplate template, StateFileResourceInstance targetResource)
        {
            if (self == null)
            {
                throw new ArgumentNullException(nameof(self));
            }

            var context = new TerraformAttributeGetterContext(self.GetResolvedAttributeName(template));

            targetResource.Attributes.Accept(new TerraformAttributeGetterVisitor(), context);
            return(context);
        }