public void AssertAttributeAsBlocksWillBeRenderedAsBlocks(string resourceType, string attributeName)
        {
            var resource  = AwsSchema.GetResourceSchema(resourceType);
            var attribute = resource.GetAttributeByPath(attributeName);

            attribute.IsBlock.Should().BeTrue();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="EmitterContext"/> class.
 /// </summary>
 /// <param name="emitter">The emitter.</param>
 /// <param name="currentResourceType">Type of the current resource.</param>
 /// <param name="currentResourceName">Name of the current resource.</param>
 public EmitterContext(IHclEmitter emitter, string currentResourceType, string currentResourceName)
 {
     this.Emitter             = emitter;
     this.CurrentResourceName = currentResourceName;
     this.CurrentResourceType = currentResourceType;
     this.ResourceSchema      = AwsSchema.GetResourceSchema(this.CurrentResourceType);
 }
        public void GetResourceByNameShouldThrowForUnknownTerraformResource()
        {
            const string TerraformName   = "aws_foo_bar";
            var          expectedMessage = $"Resource \"{TerraformName}\" not found.";

            Action action = () => AwsSchema.GetResourceSchema(TerraformName);

            action.Should().Throw <KeyNotFoundException>().WithMessage(expectedMessage);
        }
        public void AssertGetResourceSchemaWithUnknownAwsTypeThrows()
        {
            const string UnknownAwsType = "AWS::EC2::FooBar";

            var expectedMessage =
                $"Resource \"{UnknownAwsType}\": No corresponding Terraform resource found. If this is incorrect, please raise an issue.";
            Action action = () => AwsSchema.GetResourceSchema(UnknownAwsType);

            action.Should().Throw <KeyNotFoundException>().WithMessage(expectedMessage);
        }
        public void InvalidPathToAttributeWithValueSchemaShouldThrow()
        {
            const string InvalidAttribute = "managed_policy_arns.max_session_duration";
            var          expectedMessage  = $"Resource does not contain an attribute at\"{InvalidAttribute}\".";

            var    resource = AwsSchema.GetResourceSchema("aws_iam_role");
            Action action   = () => resource.GetAttributeByPath(InvalidAttribute);

            action.Should().Throw <KeyNotFoundException>().WithMessage(expectedMessage);
        }
        public void GetResourceByNameShouldThrowForUnknownAwsResource()
        {
            const string AwsName         = "AWS::Foo::Bar";
            var          expectedMessage =
                $"Resource \"{AwsName}\": No corresponding Terraform resource found. If this is incorrect, please raise an issue.";

            Action action = () => AwsSchema.GetResourceSchema(AwsName);

            action.Should().Throw <KeyNotFoundException>().WithMessage(expectedMessage);
        }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TerraformAttributeSetterContext"/> class.
 /// </summary>
 /// <param name="intrinsicInfo">The intrinsic information.</param>
 /// <param name="template">Reference to parsed CloudFormation template.</param>
 /// <param name="resource">Reference to resource being updated.</param>
 /// <param name="inputs">The list of input variables and data sources.</param>
 public TerraformAttributeSetterContext(
     IReadOnlyCollection <IntrinsicInfo> intrinsicInfo,
     ITemplate template,
     StateFileResourceDeclaration resource,
     IList <InputVariable> inputs)
 {
     this.Template       = template;
     this.IntrinsicInfos = intrinsicInfo;
     this.Resource       = resource;
     this.Inputs         = inputs;
     this.Schema         = AwsSchema.GetResourceSchema(resource.Type);
 }
        public void AssertGetResourceSchemaWithValidAwsTypeDoesNotThrow()
        {
            Action action = () => AwsSchema.GetResourceSchema("AWS::EC2::Instance");

            action.Should().NotThrow();
        }