Skip to content

Commit

Permalink
Update deployement parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
kbeaugrand committed Jun 5, 2023
1 parent 8ff19c8 commit e4aecba
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 59 deletions.
1 change: 1 addition & 0 deletions src/AzureIoTHub.Portal.Domain/ConfigHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@ public abstract class ConfigHandler
public abstract string AWSS3StorageConnectionString { get; }
public abstract string AWSBucketName { get; }
public abstract string AWSAccountId { get; }
public abstract IEnumerable<string> AWSGreengrassRequiredRoles { get; }
}
}
1 change: 1 addition & 0 deletions src/AzureIoTHub.Portal.Infrastructure/ConfigHandlerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ internal abstract class ConfigHandlerBase : ConfigHandler
internal const string AWSS3StorageConnectionStringKey = "AWS:S3Storage:ConnectionString";
internal const string AWSBucketNameKey = "AWS:BucketName";
internal const string AWSAccountIdKey = "AWS:AccountId";
internal const string AWSGreengrassRequiredRolesKey = "AWS:GreengrassRequiredRoles";

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace AzureIoTHub.Portal.Infrastructure
{
using System.Collections.Generic;
using AzureIoTHub.Portal.Domain.Shared.Constants;
using Microsoft.Extensions.Configuration;

Expand Down Expand Up @@ -90,5 +91,6 @@ internal DevelopmentConfigHandler(IConfiguration config)
public override string AWSS3StorageConnectionString => this.config[AWSS3StorageConnectionStringKey]!;
public override string AWSBucketName => this.config[AWSBucketNameKey]!;
public override string AWSAccountId => this.config[AWSAccountIdKey]!;
public override IEnumerable<string> AWSGreengrassRequiredRoles => this.config.GetSection(AWSGreengrassRequiredRolesKey).Get<string[]>()!;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ internal ProductionAWSConfigHandler(IConfiguration config)
public override string AWSS3StorageConnectionString => this.config[AWSS3StorageConnectionStringKey]!;
public override string AWSBucketName => this.config[AWSBucketNameKey]!;
public override string AWSAccountId => this.config[AWSAccountIdKey]!;
public override IEnumerable<string> AWSGreengrassRequiredRoles => this.config.GetSection(AWSGreengrassRequiredRolesKey).Get<string[]>()!;


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace AzureIoTHub.Portal.Infrastructure
{
using System.Collections.Generic;
using AzureIoTHub.Portal.Domain.Shared.Constants;
using Microsoft.Extensions.Configuration;

Expand Down Expand Up @@ -94,5 +95,6 @@ internal ProductionAzureConfigHandler(IConfiguration config)
public override string AWSBucketName => throw new NotImplementedException();
public override string AWSAccountId => throw new NotImplementedException();

public override IEnumerable<string> AWSGreengrassRequiredRoles => throw new NotImplementedException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,14 @@ public async Task<DeviceCredentials> GetEdgeDeviceCredentials(IoTEdgeDevice devi
{
var createCertificateTuple = await GenerateCertificate(device.DeviceName);

_ = await this.amazonIoTClient.AttachPolicyAsync(new AttachPolicyRequest
foreach (var item in this.configHandler.AWSGreengrassRequiredRoles)
{
PolicyName = "GreengrassV2IoTThingPolicy",
Target = createCertificateTuple.Item2
});

_ = await this.amazonIoTClient.AttachPolicyAsync(new AttachPolicyRequest
{
PolicyName = "GreengrassCoreTokenExchangeRoleAliasPolicy",
Target = createCertificateTuple.Item2
});
_ = await this.amazonIoTClient.AttachPolicyAsync(new AttachPolicyRequest
{
PolicyName = item,
Target = createCertificateTuple.Item2
});
}

return createCertificateTuple.Item1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ private DevelopmentConfigHandler CreateDevelopmentConfigHandler()
[TestCase(ConfigHandlerBase.AWSS3StorageConnectionStringKey, nameof(ConfigHandlerBase.AWSS3StorageConnectionString))]
[TestCase(ConfigHandlerBase.CloudProviderKey, nameof(ConfigHandlerBase.CloudProvider))]
[TestCase(ConfigHandlerBase.AWSBucketNameKey, nameof(ConfigHandlerBase.AWSBucketName))]
[TestCase(ConfigHandlerBase.AWSAccountIdKey, nameof(ConfigHandlerBase.AWSAccountId))]
[TestCase(ConfigHandlerBase.AWSGreengrassRequiredRolesKey, nameof(ConfigHandlerBase.AWSGreengrassRequiredRoles))]
public void SettingsShouldGetValueFromAppSettings(string configKey, string configPropertyName)
{
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ private ProductionAWSConfigHandler CreateProductionAWSConfigHandler()
[TestCase(ConfigHandlerBase.AWSS3StorageConnectionStringKey, nameof(ConfigHandlerBase.AWSS3StorageConnectionString))]
[TestCase(ConfigHandlerBase.CloudProviderKey, nameof(ConfigHandlerBase.CloudProvider))]
[TestCase(ConfigHandlerBase.AWSBucketNameKey, nameof(ConfigHandlerBase.AWSBucketName))]
[TestCase(ConfigHandlerBase.AWSAccountIdKey, nameof(ConfigHandlerBase.AWSAccountId))]
[TestCase(ConfigHandlerBase.AWSGreengrassRequiredRolesKey, nameof(ConfigHandlerBase.AWSGreengrassRequiredRoles))]

public void SettingsShouldGetValueFromAppSettings(string configKey, string configPropertyName)
{
Expand Down
Loading

0 comments on commit e4aecba

Please sign in to comment.