Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ResourceGroup and SubscriptionId fields #1433

Merged
merged 6 commits into from Feb 3, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Bicep.Core.IntegrationTests/ScenarioTests.cs
Expand Up @@ -462,5 +462,25 @@ public void Test_Issue1402()
template.SelectToken("$.resources[?(@.name == 'subDeploy')].resourceGroup")!.Should().DeepEqual("bicep-rg");
template.SelectToken("$.resources[?(@.name == 'subDeploy')].location")!.Should().BeNull();
}

[TestMethod]
public void Test_Issue1391()
{
var bicepContents = @"
resource dep 'Microsoft.Resources/deployments@2020-06-01' = {
name: 'nestedDeployment'
resourceGroup: 'bicep-rg'
subscriptionId: 'abcd-efgh'
location: 'westus'
properties: {
mode: 'Incremental'
}
}
";
var jsonOutput = CompilationHelper.AssertSuccessWithTemplateOutput(bicepContents);
var template = JToken.Parse(jsonOutput);
template.SelectToken("$.resources[?(@.name == 'nestedDeployment')].subscriptionId")!.Should().DeepEqual("abcd-efgh");
template.SelectToken("$.resources[?(@.name == 'nestedDeployment')].resourceGroup")!.Should().DeepEqual("bicep-rg");
}
}
}
6 changes: 6 additions & 0 deletions src/Bicep.Core/TypeSystem/Az/AzResourceTypeFactory.cs
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Collections.Generic;
using Bicep.Core.Resources;
using Bicep.Core.Emit;

namespace Bicep.Core.TypeSystem.Az
{
Expand Down Expand Up @@ -74,6 +75,11 @@ private static ObjectType AddBicepResourceProperties(ObjectType objectType, Azur
var scopeRequiredFlag = (scope == Azure.Bicep.Types.Concrete.ScopeType.Extension) ? TypePropertyFlags.Required : TypePropertyFlags.None;
properties.Add(new TypeProperty("scope", new ResourceReferenceType("resource", ResourceScope.Resource), TypePropertyFlags.WriteOnly | scopeRequiredFlag));
}
if (objectType.Name == TemplateWriter.NestedDeploymentResourceType)
TSunny007 marked this conversation as resolved.
Show resolved Hide resolved
{
properties.Add(new TypeProperty("resourceGroup", LanguageConstants.String));
properties.Add(new TypeProperty("subscriptionId", LanguageConstants.String));
}

// TODO: remove 'dependsOn' from the type library and add it here

Expand Down